formatting - PHP simpleXML how to save the file in a formatted way? -


I am trying to add some data to an existing XML file using PHP's SimpleXML. The problem is that it adds all the data in a single line:

  lift; Name & gt; Blah & lt; / Name & gt; & Lt; Class & gt; Blah & lt; / Class & gt; & Lt; Area & gt; Blah & lt; / Area & gt; ...  

and so on. How to apply line breaks all in one line?

How do I create it?

  & lt; Name & gt; Blah & lt; / Name & gt; & Lt; Classes & gt; Blah & lt; / Square & gt; & Lt; Region & gt; Blah & lt; / Region & gt;  

I am using the asXML () function.

Thank you.

You can use it to reformat your code:

< Pre> $ dom = new DOMDocument ('1.0'); $ Dom- & gt; Protected WhiteSpace = false; $ Dom- & gt; FormatOutput = true; $ Dom- & gt; LoadXML ($ simpleXml-> asXML ()); Echo $ dom- & gt; SaveXML ();

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -