Re: How to prevent DomDocument from adding a !DOCTYPE.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rob Richards wrote:
Mathijs wrote:

I have some HTML content:
<div id="test1">
  <div id="test2" class="testClass">
    <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.

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

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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux