[15.12.2006 18:08] Martel Valgoerad wrote:
It's easier to call $doc->createTextNode('body', 'Text of body')
than to write four lines of code.
Isn't that the same as $doc->addChild('body', 'Text of body'); with
simplexml? I've tested with:
<?php
$xml = '<html/>';
$doc = new SimpleXMLElement($xml);
$doc->addChild('body', 'some text');
var_dump($doc->asXml());
$doc = new DOMDocument();
$doc->loadXML($xml);
$body = $doc->createElement('body');
$content = $doc->createTextNode('some text');
$body->appendChild($content);
$doc->firstChild->appendChild($body);
var_dump($doc->saveXml());
?>
The output is:
string(58) "<?xml version="1.0"?>
<html><body>some text</body></html>
"
string(58) "<?xml version="1.0"?>
<html><body>some text</body></html>
"