Re: How to prevent DomDocument from adding a !DOCTYPE.
| From: | Mathijs | Date: | Thu, 18 Jan 2007 14:06:44 +0000 |
| Subject: | Re: How to prevent DomDocument from adding a !DOCTYPE. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247325@lists.php.net to get a copy of this message | ||
Rob Richards wrote:
Mathijs wrote:I have it fixed now. You need to have a <meta> tag with the right content-type in the parsed HTML. If you don't do this, the parser doesn't know the right content-type. Also, there was something wrong with my own post/get handling. So that caused some problems also.I have some HTML content: <div id="test1"> <div id="test2" class="testClass">If this were XHTML or you were working with complete HTML documents, then you would have a shot. Being HTML snippets, you are going to run into problems (different encodings, possibility of entities, etc..) - all of which need to be handled. You could probably hack the snippet a bit to "create" a full HTML document, but there's still no guarantee it will work correctly between different snippets. On top of that, unlike working with XML, there is no way to output a subtree of HTML. You would need to use the XML serialization routines, which would most likely change the structure of your document (it would be XHTML compliant now). Rob<span style="font-color: #900;" class="secondTestClass"> Testing<br> </span> ØøÅå_^{}\[~]|€ÆæßÉ@£$¥èéùìòÇ!"#¤%&'()*+,ÖÑܧ¿äöñüà-./:;<=>?¡Ä</div> </div> Now i need to parse the HTML by getting all the class and id attributes and replace them with something else, and after that return the modified HTML.