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 Quote Link to comment 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> Quote Link to comment 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>'; ?> Quote Link to comment 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.... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.