PDA

View Full Version : Updating an XML File with PHP



acid_core
12-12-2008, 06:22 AM
Dear all,

I am trying to update an existing XML file with PHP using DOMDocument. My code starts like this:

$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->load("error_log.xml");

$start = $doc->getElementsByTagName("errors")->item(0);

$element = $doc->createElement("error");
$element = $doc->appendChild($element);

My problem is, the new elements I am trying to append are added in a single line although I am using formatOutput=true.!!

Can anyone help me on this? I would really want a good looking XML file with line breaks and indenting... Thank you in advance

maneetpuri
12-15-2008, 12:12 PM
Hi,

When I used it, it produced a neat looking XML for me, I am not sure why its happening with you. Try adding formatOutPut after loading the XML file.

Cheers,

~Maneet
Lexolution IT Services
Web Design & Development company (http://www.lexolutionit.com)