Connecting Tech Pros Worldwide Help | Site Map

domDocument and XML

  #1  
Old July 17th, 2005, 11:47 AM
Andrew M.
Guest
 
Posts: n/a
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, 11:48 AM
Felix
Guest
 
Posts: n/a

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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML/ASP Help Needed lreames@gmail.com answers 16 February 2nd, 2006 05:05 PM
Which port isMsxml2.DOMDocument using in server to server requests pieV answers 0 November 12th, 2005 03:53 AM
Convert DOMDocument to System.Xml.Document? Dean Slindee answers 3 November 12th, 2005 02:11 AM
XML DOM Setup with PHP fionathomson answers 3 November 10th, 2005 08:45 PM
PHP Version 4.3.10 - Warning: domdocument() expects at least 1 parameter, 0 given Mini Mouse answers 1 July 17th, 2005 01:29 PM