PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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?
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.
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.