Connecting Tech Pros Worldwide Help | Site Map

domDocument and XML

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 10:47 AM
Andrew M.
Guest
 
Posts: n/a
Default 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.

  #2  
Old July 17th, 2005, 10:48 AM
Felix
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.