When you use simplexml_load_file(), the variable that you load it into ($xml, in your case) becomes synonymous with the root element of your XML. So in your foreach loop, what you want is the element <link> which is under root element <links> - "$xml->link->links" is not specifying this. Change to "$xml->link".

Make sense?