dordal Posted July 31, 2007 Share Posted July 31, 2007 Folks- What is the best way to view the contents of a DomDocument Object? print_r() and var_dump() just give me empty objects. Here is my code, if you're curious: $dom = new DOMDocument(); $dom->loadHTML("<html><body><p>Hello World</p></body></html>"); print_r($dom); D Link to comment https://forums.phpfreaks.com/topic/62714-debugging-domdocument-objects-print_r-doesnt-work/ Share on other sites More sharing options...
Wildbug Posted July 31, 2007 Share Posted July 31, 2007 I'm sure print_r is working nicely; however, the following might get you what you expect: <pre><?php echo htmlentities(print_r($dom,1)); ?></pre> Link to comment https://forums.phpfreaks.com/topic/62714-debugging-domdocument-objects-print_r-doesnt-work/#findComment-312139 Share on other sites More sharing options...
Barand Posted July 31, 2007 Share Posted July 31, 2007 try <?php $dom = new DOMDocument(); $dom->loadHTML("<html><body><p>Hello World</p></body></html>"); $xml = simplexml_import_dom($dom); echo '<pre>', print_r($xml, true), '</pre>'; ?> Link to comment https://forums.phpfreaks.com/topic/62714-debugging-domdocument-objects-print_r-doesnt-work/#findComment-312146 Share on other sites More sharing options...
dordal Posted July 31, 2007 Author Share Posted July 31, 2007 try <?php $dom = new DOMDocument(); $dom->loadHTML("<html><body><p>Hello World</p></body></html>"); $xml = simplexml_import_dom($dom); echo '<pre>', print_r($xml, true), '</pre>'; ?> Yeah, tried that. It will certainly work if nothing else does.... I just don't get why print_r won't print out the contents of the object. It seems to work fine on most other objects, but maybe the DOM people haven't made the toString() function yet. I guess.... Link to comment https://forums.phpfreaks.com/topic/62714-debugging-domdocument-objects-print_r-doesnt-work/#findComment-312185 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.