1

I am writing a task to import a XML. Debugging is a pain as both var_dump and print_r return seemingly empty objects for DOM objects like DOMElement and DOMNodeList list, looking so:

object(DOMElement)#330 (0) {} object(DOMNodeList)#335 (0) {} 

But they are not empty as I can read the values.

What debugging options have I instead?

1

2 Answers 2

2

For a DomDocument I var_dump using the xml output.

var_dump($dom->saveXML()); 

For a DOMElement, I use (as seen here):

var_dump($domElement->ownerDocument->saveXML($domElement)); 

But DOMNodeList, I have no idea. Maybe you have to attach/append it to a DomDocument, and then var_dump it.

And btw, not showing internals of a DomDocument is reported (here: Reflection).

Sign up to request clarification or add additional context in comments.

Comments

1

Solution: i wrote own monitoring function 'dom_test'

 function dom_test($DOM) { echo '<h1>'.get_class($DOM).'</h1>'; // easiest way to traverse: echo 'LENGTH: '. @$DOM->length ."\n"; // if NodeList echo 'TAG: '. @$DOM->tagName ."\n"; // if Element echo 'CHILDS: '. @$DOM->childNodes->length ."\n"; // etc. } 

hope this could help you!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.