tags:

views:

106

answers:

2

What's the "trick" to save an XML file that visually would result neatly formatted?

such as:

<xml>
   <item>foo</item>
</xml>

and not:

<xml><item>foo</item></xml>
A: 

See the comments on the documentation

David Dorward
That is a horribly verbose and unnecessarily complex. See Gumbo's answer on the OP's comments.
Justin Johnson
+2  A: 

If the proper format of Xml is important for you instead of SimpleXml use the DOM (also included and much more complex) extension that has a property for this:

$xml->formatOutput = true;
Elzo Valugi
See linked duplicate for full code example
Gordon
I think I'll use dom_import_simplexml before saving
cesko80