So I wanted to parse this XML:
The poorly documented fact in play here is that when you select a namespace with ->children
, it remains in effect for descendent nodes.
So when you ask for $sxe->children("soapenv", true)->Body->requestContactResponse
, SimpleXML assumes you are still talking about the "soapenv"
namespace, so is looking for the element
, which doesn't exist.
To switch back to the default namespace, you need to call ->children
again, with a NULL
namespace:
$sx->children("soapenv", true)->Body->children(NULL)->requestContactResponse->requestContactReturn->id