I'm trying to use XPath with PHP and I can't get it to simply return a value. Could someone please let me know what I'm doing wrong?
The result I get is:
Array ( [0] => SimpleXMLElement Object ( ) )
but W3Schools says the result is supposed to be:
Array
(
[0] => SimpleXMLElement Object
(
[0] => Jani
)
)
Here's what I'm using:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
PHP:
<?php
$XMLfile = "test.xml";
$xml = simplexml_load_file($XMLfile);
$result = $xml->xpath("from");
print_r($result);
?>
echo $xml->from?