Using DOMDocument->SaveXML ... is it possible to have XML more readerfriendly?

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

    Using DOMDocument->SaveXML ... is it possible to have XML more readerfriendly?

    Hi,

    When using the Save() and SaveXML() functions I am able to output xml
    on a screen or save to file. The only issue is that I would prefer to
    have it a bit more readable. For example:

    Current:

    <?xml... ?><root><person ><first_name>Mo nty</first_name><sur name>Burns</
    surname></person></root>

    This is better:

    <?xml... ?>
    <root>
    <person>
    <first_name>Mon ty</first_name>
    <surname>Burn s</surname>
    </person>
    </root>

    I have an idea involving lots of str_replace's - e.g.
    str_replace("<p erson>", "\n <person>", $xml) - but thought Id check
    to see if maybe an option or setting exists to do this. Obviously my
    xml is a bit more complicated that the above so it would help as it is
    for an external API so I want it to be easy to read. I had a look in
    the PHP Docu and notice that there are options you can set in Save and
    SaveXML but didnt seem to be any to do what I was after (or maybe I
    just didnt understand them properly). Any help would be much
    appreciated.

    Burnsy
Working...