How to properly add newlines to an XML string in PHP?

Posted by stormist on Stack Overflow See other posts from Stack Overflow or by stormist
Published on 2010-05-07T01:22:03Z Indexed on 2010/05/07 1:28 UTC
Read the original article Hit count: 304

Filed under:
|
|

I have some xml that I manually construct in a function that is something like:

$xml = "<myxml>";
$xml .= "<items>";
$xml .= "<item1>blah</item1>";
$xml .= "</items>";
$xml .= "</myxml>";

When I output the string though I'd like the newlines to be present. How can I add this to the string without affecting a web service accepting the xml? Do newlines in XML even matter?

© Stack Overflow or respective owner

Related posts about Xml

Related posts about php