DomDocument, insert HTML Element

From: Date: Fri, 12 Nov 2004 10:06:52 +0000
Subject: DomDocument, insert HTML Element
Groups: php.xml.dev 
Request: Send a blank email to php-xml-dev+get-504@lists.php.net to get a copy of this message
Hi, I have a problem I can't really resolve myself. It would be great if someone could give me some hints. I have a DomDocument created with: $doc = new DomDocument('1.0', 'UTF-8'); $doc->resolveExternals = true; $doc->substituteEntities = true; 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); var_dump::display($this->doc->saveXML()); Var dump gives: <?xml version="1.0" encoding="UTF-8"?> <article id="2335"><body>Some kind of &lt;a href="http://cos.com"&gt;HTML&lt;/a&gt;</body></article> As you can see, all the HTML special chars where transformed to entities. How can I prevent that happening? As a side note: I'm pretty new here, so if it's really frequently asked question, please don't be mad and direct me to the solution instead (I have browsed the threads up to may, though). Thanks in advance. -- Martel Valgoerad (a.k.a. Michal Minicki) | "You don't stop laughing because alea.iacta.est | Martel -> martel@post.pl | you grow old. You grow old because Web Page: http://www.aie.pl | you stop laughing." M. Pritchard

« previous php.xml.dev (#504) next »