captaincaveman
July 3rd, 2008, 04:40 AM
Hi all,
Nice forum, been looking a few times on this site on various tutorials but never got round to registering till now when i came across a problem with the xml tutorial.
http://www.kirupa.com/developer/php/php5_simpleXML.htm
Managed to get it working alright, however, im stuck on getting a page to display just the most recent 3 entries (or the top 3 entries) of the xml file.
I can get it to working without any extra tags or attributes in the xml file such as
<news>
<story>some news item blah blah</story>
<story>another news story</story>
</news
using the following php
<?php
// set name of XML file
$file = "news.xml";
// load file
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
// access each <item>
echo "<p>" . $xml->story[0] . "</p>";
echo "<p>" . $xml->story[1] . "</p>";
echo "<p>" . $xml->story[2] . "</p>";
?>
But im struggling with the tutorials xml example with more data involved in the xml file.
Any help would be appreciated
:)
Nice forum, been looking a few times on this site on various tutorials but never got round to registering till now when i came across a problem with the xml tutorial.
http://www.kirupa.com/developer/php/php5_simpleXML.htm
Managed to get it working alright, however, im stuck on getting a page to display just the most recent 3 entries (or the top 3 entries) of the xml file.
I can get it to working without any extra tags or attributes in the xml file such as
<news>
<story>some news item blah blah</story>
<story>another news story</story>
</news
using the following php
<?php
// set name of XML file
$file = "news.xml";
// load file
$xml = simplexml_load_file($file) or die ("Unable to load XML file!");
// access each <item>
echo "<p>" . $xml->story[0] . "</p>";
echo "<p>" . $xml->story[1] . "</p>";
echo "<p>" . $xml->story[2] . "</p>";
?>
But im struggling with the tutorials xml example with more data involved in the xml file.
Any help would be appreciated
:)