# XML output from PHP

**URL:** <https://forum.kirupa.com/t/xml-output-from-php/252302>\
**Category:** flash\
**Created:** [February 18, 2008, 9:00pm UTC](https://forum.kirupa.com/t/xml-output-from-php/252302 "2008-02-18T21:00:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rocketrud](https://avatars.discourse-cdn.com/v4/letter/r/b19c9b/32.png) [@Rocketrud](https://forum.kirupa.com/u/Rocketrud)\
**Post date:** [February 18, 2008, 9:00pm UTC](https://forum.kirupa.com/t/xml-output-from-php/252302/1 "2008-02-18T21:00:09Z")

</div>

I would like to produce the following xml document from PHP

\<slideshow\>  
\<photo url=“DO NOT DELETE ME” day= “6” month= “FEBRUARY” description=“Current Day Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “7” month= “FEBRUARY” description=“Day 2 Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “8” month= “FEBRUARY” description=“Day 3 Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “9” month= “FEBRUARY” description=“Day 4 Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “10” month= “FEBRUARY” description=“Day 5 Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “11” month= “FEBRUARY” description=“Day 6 Description” /\>  
\<photo url=“DO NOT DELETE ME” day= “12” month= “FEBRUARY” description=“Day 7 Description” /\>  
\</slideshow\>

Here is the PHP that I have

$xml\_output = "\<?xml version=“1.0”?\>  
";  
$xml\_output .= "\<slideshow\>  
";

foreach($result as $row) {

```
$xml_output .= " &lt;month =\"".$row['eventStartDate'] ."\" /&gt;

```

“;  
$xml\_output .= " \<day =”".$row[‘eventEndDate’] ."" /\>  
“;  
$xml\_output .= " \<description =”".$row[‘eventSummary’] ."" /\>  
";

```
 // Escaping illegal characters 
    $row['imagedesc'] = str_replace("&", "&amp;", $row['imagedesc']); 
    $row['imagedesc'] = str_replace("&lt;", "&lt;", $row['imagedesc']); 
    $row['imagedesc'] = str_replace("&gt;", "&gt;", $row['imagedesc']); 
    $row['imagedesc'] = str_replace("\"", "&quot;", $row['imagedesc']); 

```

}

$xml\_output .= “\<slideshow\>”;

echo $xml\_output;
