xml file layout

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

    #1

    xml file layout

    I have created an xml file using normal file write (was less code than DOM),
    the layout of which is nice and easy to view both in a text editor (eg,
    wordpad) and in a browser.

    eg:
    <xml header blah.....>

    <books>

    <book>
    <title>Contents </title>
    <author>Content s</author>
    </book>

    </books>

    When I use DOM to update the file with new items, they ALL end up written to
    the file as a continuous line that starts before the closing </bookstag.
    So the file ends up looking like this:

    <xml header blah.....>

    <books>

    <book>
    <title>Contents </title>
    <author>Content s</author>
    </book>

    <book><title>Co ntents</title><author>C ontents</author></book><book><tit le>Contents</title><author>C ontents</author></book></books>

    I have tried a number of things, and am having no luck. I either get it
    correctly formatted with only the new entries (loosing all the existing
    content), or I get the above result.
    Is there anyway to get DOM to correctly format the new items? If so, how do
    I do it?

    Cheers,

    Phil


  • Ambush Commander

    #2
    Re: xml file layout

    Is there anyway to get DOM to correctly format the new items? If so, how do
    I do it?
    PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


    $document->preserveWhiteS pace = false;
    $document->load('xmlfile. xml');
    $document->formatOutput = true;

    Comment

    Working...