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?
The new lines aren't required but you can use the PHP_EOL constant which is a cross platform way of finding the new line character. i.e.
$xml = "<myxml>".PHP_EOL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With