I am able to load an XML document and create a SimpleXMLElement - I am also able to query it using XPATH but I am perplexed by the behavior I am noticing. When I load the XML and create a SimpleXMLElement - it is of the below structure
XML is as below
<StructuredXMLResume>
<ContactInfo>
<PersonName>
<FullName>Tom Jones</FullName>
<GivenName>Tom</GivenName>
<MiddleName />
<FamilyName>Jones</FamilyName>
</PersonName>
</ContactInfo>
</StructuredXMLResume>
[0] => SimpleXMLElement Object
(
[PersonName] => SimpleXMLElement Object
(
[FullName] => Tom Jones
[GivenName] => Tom
[MiddleName] => SimpleXMLElement Object
(
)
[FamilyName] => Jones
)
When I execute $xml->xpath('//PersonName')
I get the right result which is as below
[0] => SimpleXMLElement Object
(
[FullName] => Tom Jones
[GivenName] => Tom
[MiddleName] => SimpleXMLElement Object
(
)
[FamilyName] => Jones
)
But when I execute $xml->xpath('//GivenName')
I get the below result - which I am unable to understand
[0] => SimpleXMLElement Object
(
)
Can someone please help me understand what my error is?