Re: [PHP-XML-DEV] DomDocument, insert HTML Element
[email protected] ("Rob Richards") Fri, 12 Nov 2004 05:57:33 -0500
| Newsgroups | php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
Wrong list as this list is for development of the xml extensions not support
for them.
Anways, with php 5.1 you use the new appendXML method of DOMFragement
object:
$HTML = 'Some kind of <a href="http://cos.com">HTML</a>';
$bodyfrag = $doc->createDocumentFragment();
$bodyfrag->appendXML($HTML);
$body = $doc->createElement('body');
$body->appendChild($bodyfrag);
$art->appendChild($body);
In your example you are trying to used mixed content for the contents of an
element which is bad.
Rob
----- Original Message -----
From: Martel Valgoerad
> And then I wish to add $HTML which is taken directly from the database (so
I
> don't have any influence on the content - but I am sure that's a well
formed
> xhtml):
>
> $art = $doc->createElement('article');
> $art->setAttribute('id', 2335);
>
> $HTML = 'Some kind of <a href="http://cos.com">HTML</a>';
> $body = $doc->createElement('body', $HTML);
> $art->appendChild($body);
>
> $doc->appendChild($art);