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!
- <item>
<photo>images/01.jpg</photo>
<h1>Headline One Goes Here</h1>
<p>Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max</p>
<url>http://www.cnet</url>
</item>
What i need to do is read the data from mysql database and insert the info into each of the tags. I know how to read the data into a php file and put each of the different tags like photo, url, etc into strings like $photo and $url. So i know how to do it in a php file, but how do i get those strings to appear in an xml file that i already have set up?
<?php
$row = array(
'photo' => 'images/01.jpg',
'headline' => '-->Headline One Goes Here<--',
'text' => 'Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max Put text here. You can add 2 lines max'
);
$item = new SimpleXMLELement('<item />');
$item->photo = $row['photo'];
$item->h1 = $row['headline'];
$item->p = $row['text'];
echo $item->asXML();
?>
it will e.g. take care of the proper encoding of the document; in this case