Re: DOM Question. No pun intended.
| From: | Rob Richards | Date: | Thu, 14 Sep 2006 17:50:03 +0000 |
| Subject: | Re: DOM Question. No pun intended. | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241796@lists.php.net to get a copy of this message | ||
mwilliams@infinitydatasystems.com wrote:
Rob, I wasn't aware that that would work. I mean I suppose it should, but basically this is what I'm doing: 1) Create a new DOMDocument 2) DOMDocument->loadHTML() 3) find the elements I want with getElementsByTag() then finding the one with the correct attributes . . .at this point, I need the equivalent of DOMDocument->saveHTML() so that it outputs the *exact* html content. Are you saying that saveXML() will do what I want it to do; tags and all? It is the best option, though in reality there may not be a way to do this exactly as you want due to HTML not having to be valid XML. By exact, unless the input is valid XHTML, loadHTML is going to cause the HTML to be fiexed to be proper XML, so using $doc->saveXML($node) you will get the serialized of the element as it was created when loading the HTML (this includes any "fixes" the parser may have made.Rob