Results 1 to 2 of 2

Thread: Updating an XML File with PHP

  1. #1
    Join Date
    Dec 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post 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

  2. #2
    Join Date
    Sep 2008
    Posts
    56
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Default 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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •