-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.

2
  • A bit like this? stackoverflow.com/q/7086165/78845 Commented Aug 30, 2011 at 9:59
  • 2
    What is your concrete problem or question? What have you tried so far? What does not work? Please post your code. Commented Aug 30, 2011 at 13:10

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Please don't link to w3schools, see w3fools for reasons why.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.