Re: How to prevent DomDocument from adding a !DOCTYPE.
- From: rrichards@xxxxxxxxxxxxxxxx (Rob Richards)
- Date: Wed, 17 Jan 2007 08:37:37 -0500
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
.
- Follow-Ups:
- Re: How to prevent DomDocument from adding a !DOCTYPE.
- From: Mathijs
- Re: How to prevent DomDocument from adding a !DOCTYPE.
- References:
- How to prevent DomDocument from adding a !DOCTYPE.
- From: Mathijs van Veluw
- Re: How to prevent DomDocument from adding a !DOCTYPE.
- From: Mathijs
- How to prevent DomDocument from adding a !DOCTYPE.
- Prev by Date: web form data to arrays?
- Next by Date: Re: [PHP] web form data to arrays?
- Previous by thread: Re: [PHP] Re: How to prevent DomDocument from adding a !DOCTYPE.
- Next by thread: Re: How to prevent DomDocument from adding a !DOCTYPE.
- Index(es):
Relevant Pages
|