Re: doc root
| From: | Rob Richards | Date: | Fri, 27 Jun 2003 16:53:54 +0000 |
| Subject: | Re: doc root | ||
| References: | 1 | Groups: | php.xml.dev |
| Request: | Send a blank email to php-xml-dev+get-146@lists.php.net to get a copy of this message | ||
From: Kevin Waterson
> I wish to create a new xml string.
> Is there a method like the old add_root to set the
> document root?
> eg: if I have something like
> $dom = new domDocument;
One way to do this is to do (note that appendChild does NOT check if a root
node already exists):
$dom = new domDocument();
$root = $dom->appendChild(new domElement("elementname", "elementvalue"));
// dump node
echo $dom->saveXML($root);
// dump document
echo $dom->saveXML();
Rob