domDocument and XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew M.

    domDocument and XML

    I am using a php5 script to insert data into an xml file. The problem I
    am having is that when I insert a new child node, it is inserted on the
    same line as the node it is supposed to be inserted before. It all works
    but makes for a sloppy XML file after inserting new child nodes.

    example:

    <songs>
    <song artist="blah"/><song artist="blah2"/>
    </songs>

    instead of

    <songs>
    <song artist="blah"/>
    <song artist="blah2"/>
    </songs>

    This is how I would like it. How do I get it to \r\n after inserting the
    new child?

    Thanks in advance for any help.
  • Felix

    #2
    Re: domDocument and XML

    What you need is to tidy up your XML *after* generating it.
    Look up Function Reference -> Tidy Functions in the PHP5
    manual. It's a binding for HTML Tidy, but it might just
    work for XML, or maybe you can find a similar, XML-specific
    library.

    Hope this helps,
    Felix

    Comment

    Working...