Hi.
First I apologise if there is a better place to post this. Please let
me know. I also apologise in advance if this is a really stupid
mistake, but now seem to be bashing head against wall.
I have some code that is creating an xml doc
$dom = new DOMDocument();
$xmlDoc = $dom->appendChild($d om->createElement( 'root'));
etc.
that is then echo d
$dom->formatOutput = true;
ob_clean();
$dom->save('php://output');
also tried
echo $dom->saveXML();
and it results in (inside the -----)
----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<root>
<user id="9">
<firstname>Ti m</firstname>
<lastname>D</lastname>
<email></email>
<houseName>Th e Station</houseName>
<houseNo>259</houseNo>
<street>Waterlo o Rd</street>
<village>Waterl oo</village>
<town>London</town>
<county>Londo n</county>
<postcode>SE1 8RW</postcode>
</user>
</root>
-----------------------------------------------------------------------
Which looks a bit odd - in Firefox there is a blank line before the
xml
and I get the message (By the time it gets back to login.php it has
gone back through a HTTPResponse body.
Warning: DOMDocument::lo adXML() [function.DOMDoc ument-loadXML]: XML
declaration allowed only at the start of the document in Entity, line:
2 in /web/zzz/login.php on line 40
Which makes me think the newline at the beginning is causing the
problem
Any ideas ?
Thanks for any help
First I apologise if there is a better place to post this. Please let
me know. I also apologise in advance if this is a really stupid
mistake, but now seem to be bashing head against wall.
I have some code that is creating an xml doc
$dom = new DOMDocument();
$xmlDoc = $dom->appendChild($d om->createElement( 'root'));
etc.
that is then echo d
$dom->formatOutput = true;
ob_clean();
$dom->save('php://output');
also tried
echo $dom->saveXML();
and it results in (inside the -----)
----------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<root>
<user id="9">
<firstname>Ti m</firstname>
<lastname>D</lastname>
<email></email>
<houseName>Th e Station</houseName>
<houseNo>259</houseNo>
<street>Waterlo o Rd</street>
<village>Waterl oo</village>
<town>London</town>
<county>Londo n</county>
<postcode>SE1 8RW</postcode>
</user>
</root>
-----------------------------------------------------------------------
Which looks a bit odd - in Firefox there is a blank line before the
xml
and I get the message (By the time it gets back to login.php it has
gone back through a HTTPResponse body.
Warning: DOMDocument::lo adXML() [function.DOMDoc ument-loadXML]: XML
declaration allowed only at the start of the document in Entity, line:
2 in /web/zzz/login.php on line 40
Which makes me think the newline at the beginning is causing the
problem
Any ideas ?
Thanks for any help
Comment