Needed tutorial on XML file creation

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Needed tutorial on XML file creation

Post by Trenchant »

I'm integrating a gallery into a website and I need to fill an xml file with image details from a database. I haven't been able to find just a simple way to do this. It will be used in an administration area every time new photographs are added. Here's what the xml looks like:

Code: Select all

<images>
    <pic>
        <image>gallery/1.jpg</image>
        <thumbnail>gallery/s1.jpg</thumbnail>
        <caption>Some lamp on the ground</caption>
    </pic>
</images>
For a database I'm using MySQL.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Needed tutorial on XML file creation

Post by jaoudestudios »

The xml structure is correct all you need are the headers

Code: Select all

 
<?xml version="1.0" ?> 
<images>
 <pic>
  <image>gallery/1.jpg</image>
  <thumbnail>gallery/s1.jpg</thumbnail>
  <caption>Some lamp on the ground</caption>
 </pic>
</images>
 
If its a *.php file then use...

Code: Select all

 
header('Content-Type: text/xml');
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: Needed tutorial on XML file creation

Post by jaoudestudios »

User avatar
Trenchant
Forum Contributor
Posts: 291
Joined: Mon Nov 29, 2004 6:04 pm
Location: Web Dummy IS

Re: Needed tutorial on XML file creation

Post by Trenchant »

That link to your forum worked great! Thanks a bunch. I knew there had to be an easy way of going about it.
Post Reply