lots of code take some code, share some code!

XML to PHP



This is a very simple script that passes xml to php.

Parse XML to PHP and use the data on your very own website. You can also use this code to include RSS news feeds.

This is a simple example of how to include the xml parser:

<?php
include 'xmltophp.class.php';

$files = array('rss.xml');

$xmlToPHP = new xmlToPHP;

foreach ($files as $file) {
$x = $xmlToPHP->outputHTML($file);
foreach ($x as $y => $z) {
echo '<b>'.$z['title'].'</b><div>'.$z['description'].'</div><br />';
}
}
?>

Include the class, specify the files you would like to use. Then do a simply loop and grab all the data. You will need to download the xmltophp.class.php file and store it in the directory you specify in the $files variable below.

28.10.07
Added support for remote files.

One Response to “XML to PHP”

  1. Joakim says:

    can you use pagination with this?.... if so, can someone give an example please?

Leave a Reply

 
 
Please enter the word above into the box below, the word is not case sensitive.
 
If you have trouble reading the word above then click here to load a new word.
Security word: