I am retrieving an XML data from url and I want to extract data from the particular nodes.
Here is my XML Data
<person>
<first-name>ABC</first-name>
<last-name>XYZ</last-name>
</person>
Here's my PHP code:
$content = file_get_contents($url);
$xml = simplexml_load_string($content);
foreach($xml->children() as $child)
{
echo $child->getName() . ": " . $child->first-name . "<br>";
}
PHP returns this error:
Use of undefined constant name - assumed 'name'
So where am I going wrong?