Hi all,
I have just started experimenting with php & xml.
Followed the samples came with the DOM API section on this site. I was able to load the book.xml from the file system with the code like this.
However, when I want to load from a string, like below.Code:<?php $doc = DOMDocument::load('book.xml'); echo $doc->saveXML(); $doc = new DOMDocument(); $doc->load('book.xml'); echo $doc->saveXML(); ?>
I got this error.Code:<?php $doc = DOMDocument::loadXML('<root><node/></root>'); echo $doc->saveXML(); $doc = new DOMDocument(); $doc->loadXML('<root><node/></root>'); echo $doc->saveXML(); ?>
I am using xampp for Windows 1.5.1. Anyone knows why? Please help. Many thanks.Only one top level element is allowed in an XML document. Error processing resource 'http://localhost/contest/loadXML.php'. Line 4, Position 2
<root><node/></root>
-^



Reply With Quote
Bookmarks