I am having a syntax issue. The following code prints all of the names from an XML file.
$url = 'http://my-xml-file';
$xml = simplexml_load_file($url);
foreach($xml->PERSON as $PERSON) {
echo '<div>' . $PERSON->NAME . '</div>';
}
The XML file has now changed and only has 1 person with 1 name in it. How can I modify the code above to echo a single name?
Thanks
UPDATE I have simplified it a bit but the basic XML structure looks like this:
<PERSON>
<NAME>Tom</NAME>
</PERSON>