tags:

views:

45

answers:

1
<?xml version="1.0" encoding="utf-8"?><items>
<item><title>title3</title><desc>This is some desc3</desc></item></items>

There is no line break between each node element when using asXML() to output?

how to make output the file well-structured by adding link break

<?xml version="1.0" encoding="utf-8"?>
<items>
<item>
<title>title3</title>
<desc>This is some desc3</desc>
</item>
</items>
A: 

There is no way in doing this with the normal SimpleXML extension. You can however write yourself a method/function that pretty-prints you the XML. Have a look at the php manual, someone already made the work.

If you don't want to use that method you could also switch from SimpleXML to XMLWriter which provides a method to set the indentation (XMLWriter::setIndent)of printed XML.

halfdan
Thanks halfdan, it helps
yozloy