Hope someone can help me. I'm just dipping my toe into working with XML documents and I'm having a problem. So far, I've managed to read documents without a problem but I'm now taking the next step of adding to and creating new XML sheets. I'm having a look at this article here:
http://www.devshed.com/c/a/PHP/A-Quick-Overview-of-the-XML-DOM-Extension-in-PHP-5/1/
..and trying to run this piece of code from XAMPP:
- Code: Select all
$dom=new DOMDocument('1.0','iso-8859-1');
$element=$dom->createElement('testnode','This is the root element of the new DOM document');
// insert the new element as root (child of the document)
$dom->appendChild($element);
// tell the browser the output is XML via the 'Content-Type' HTTP header
header('Content-Type: text/xml');
// display DOM document
echo $dom->saveXML();
But's it's coming up with this error message:
This page contains the following errors:
error on line 1 at column 60: Space required after the Public Identifier
Below is a rendering of the page up to the first error.
Can anyone tell me, is it XAMPP causing this error, or a problem with the code itself?
Thanks