Jump to content

Simple XML Output - formatting


dweb

Recommended Posts

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>
D123OO
M876TT
B765DC
LO122M
</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

Link to comment
Share on other sites

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 by brandon66
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.