# Xml format from php

**URL:** <https://forum.kirupa.com/t/xml-format-from-php/221235>\
**Category:** Uncategorized\
**Created:** [April 2, 2007, 6:51pm UTC](https://forum.kirupa.com/t/xml-format-from-php/221235 "2007-04-02T18:51:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AKAAirborne](https://avatars.discourse-cdn.com/v4/letter/a/e9c0ed/32.png) [@AKAAirborne](https://forum.kirupa.com/u/AKAAirborne)\
**Post date:** [April 2, 2007, 6:51pm UTC](https://forum.kirupa.com/t/xml-format-from-php/221235/1 "2007-04-02T18:51:52Z")

</div>

I am working on a script for a calendar page. The calendar read an xml page and displays the information accordingly.

The xml page is being generated from a mysql database.

I need the xml to be formatted in a specific manner in order for the calendar to work.

Example

\<year value=“2007”\>  
\<month value=“04”\>  
\<day value=“12”\>  
\<label\>This is posted in calendar square\</label\>  
\<description\>This is in pop up for that day\</description\>  
\</day\>  
\<day value=“13”\>  
\<label\>This is posted in calendar square\</label\>  
\<description\>This is in pop up for that day\</description\>  
\</day\>  
\</month\>  
\<month value=“05”\>  
\<day value=“12”\>  
\<label\>This is posted in calendar square\</label\>  
\<description\>This is in pop up for that day\</description\>  
\</day\>  
\</month\>

Right now I have this working correctly with the exception of it wanting to open and close a month tag for every entry. I am including the current code in hopes somebody can keep me from pulling the rest of my non-white hairs out(not many left).

my current xml out put look like

\<year value=“2007”\>  
\<month value=“05”\>  
\<day value=“1”\>  
\<label\>Short message\</label\>  
\<description\>message\</description\>  
\</day\>  
\</month\>  
\<month=“05”\>  
\<day value=“21”\>  
\<label\>Short message\</label\>  
\<description\>message\</description\>  
\</day\>  
\</month\>  
\<month value=“06”\>  
\<day value=“31”\>  
\<label\>Short message\</label\>  
\<description\>message\</description\>  
\</day\>  
\</month\>  
\</year\>

basically everything within each tag need to print out before the closing tag.
