Page 1 of 1

PHP DOM Inspector

Posted: Sat Sep 29, 2007 12:13 pm
by MasterArtist
Hi all,

Im doing some coding where I'm loading an HTML document into a DOM as follows:

$dom = new DOMDocument();
$dom->loadHTMLFile($source);


However its difficult to parse the created $dom because I dont have an idea of its structure, especially with HTML documents that are not well-formed.

Is there example code/program that will display the DOM generated (similar to the Firefox DOM inspector), so I know what kind of structure has been created?

Thanks

Posted: Sat Sep 29, 2007 12:32 pm
by Begby
You can do print_r() on the object or do $dom->dump_mem() and view the source. THat might give you an idea of what the hodge-podge of HTML got turned into.

Posted: Sat Sep 29, 2007 3:56 pm
by superdezign
You should know *what* you want to do with the document before you try to do anything to it. I can't think of many situations where you'd need to somehow have the whole structure laid out to you before you do anything, especially since the application won't work based on wisdom and intuition.

Posted: Sat Sep 29, 2007 5:34 pm
by MasterArtist
You should know *what* you want to do with the document before you try to do anything to it.
I know *what* I want to do with the document, but in order to do *what* I want I need to know *how* the document has been structured...

Posted: Mon Oct 01, 2007 5:22 am
by n00b Saibot
you can try Begby's procedure and find out "how"...