-
Updating an XML File with PHP
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
-
-
Re: - Updating an XML File with PHP
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
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks