SimpleXML and print_r() – why is this empty?

Don’t use print_r() or var_dump() to inspect a SimpleXMLElement, they won’t necessarily work on them because SimpleXML uses lots of magic behind the scene. Instead, look at what asXML() returns.

In your case, it doesn’t show <q1:attributes/> because they’re not in the same namespace.

Edit

To access those namespaced nodes, there are many different ways, most of them discussed here at Stack Overflow. If you can’t work it out, please open a new question, since the subject is different. Here’s 3 ways to access those elements:

$ArrayOfItem->Item->children("http://systinet.com/wsdl/com/osm/webservices/service/");
$ArrayOfItem->Item->children('q1', true);
$ArrayOfItem->Item->xpath('//q1:Attribute');

Leave a Comment

tech