dweb Posted November 20, 2013 Share Posted November 20, 2013 hi i wonder if someone can help i have some code to make a simple XML output <?php header('Content-type: text/xml'); header('Pragma: public'); header('Cache-control: private'); header('Expires: -1'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?> <xml> <customers> <id>song_path</id> <name>David</name> <promos> D123OO M876TT B765DC LO122M </promos> </customers> </xml>"; ?> my problem is; when the XML is displayed in the browser, it forces the values in <promos> onto 1 line <promos>D123OO M876TT B765DC LO122M</promos> is it possible to keep the formatting, so it outputs <promos>D123OOM876TTB765DCLO122M</promos> i have tried lots of different things but nothing seems to work \r\n \n\r \n \r <br /> <p> the only option which came close was <br />, but the XML actually displays the <br /> tag can anyone help? thank you Quote Link to comment Share on other sites More sharing options...
Barand Posted November 20, 2013 Share Posted November 20, 2013 Put "\n" in the string to replace the spaces. When you output in the browser use echo nl2br($promo); which will put <br> where the \n are Quote Link to comment Share on other sites More sharing options...
dweb Posted November 20, 2013 Author Share Posted November 20, 2013 thanks, but I dont want to output the <br /> tag, I just want line breaks excluding the tag Quote Link to comment Share on other sites More sharing options...
brandon66 Posted November 21, 2013 Share Posted November 21, 2013 (edited) How about something like this <promo1>D123OO</promo1> <promo2>M876TT</promo2> <promo3>B765DC</promo3> <promo4>LO122M</promo4> I beleive it can be done like this also <promo>D123OO</promo> <promo>M876TT</promo> <promo>B765DC</promo> <promo>LO122M</promo> //Then you can reference it like $xml->customers->promo[1]; $xml->customers->promo[2]; $xml->customers->promo[3]; $xml->customers->promo[4]; Edited November 21, 2013 by brandon66 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.