Jump to content

Debugging DomDocument objects -- print_r doesn't work


dordal

Recommended Posts

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

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....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.