Re: DomDocument, insert HTML Element
| From: | Rob Richards | Date: | Fri, 12 Nov 2004 10:57:33 +0000 |
| Subject: | Re: DomDocument, insert HTML Element | ||
| References: | 1 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-505@lists.php.net to get a copy of this message | ||
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);