-1

I Have a XML file which have some repetitive tags containing different values into it. I need to fetch those values and display in in my webpage. Please help me up in getting this.

hakre
  • 193,403
  • 52
  • 435
  • 836
OM The Eternity
  • 15,694
  • 44
  • 120
  • 182

2 Answers2

0

You can take a look to SimpleXML if you're using PHP5. You can find an intro tutorial here: http://www.w3schools.com/php/php_xml_simplexml.asp

0

Quite simply, you could do something like this:

$raw = file_get_contents('path/to/xml/file.xml');

$blankarray = array();

$blank_xml = new SimpleXMLElement($raw);
foreach($blank_xml->channel->item as $item) {
$xml_item = array(
'content' => $description,
'date' => strtotime($item->pubDate),
'type' => 'Whateva'
);
array_push($blankarray, $xml_item);
}

foreach($blankarray as $item) {
echo '<li>' . $item["content"]
. '<a href="#">' . date(DATE_RFC822, $item["date"]) . '</a>'
. '</li>';
}

Let me know if you have any questions.

John
  • 3,296
  • 2
  • 24
  • 36