Jump to content

Parsing xml attibutes


mapleleaf

Recommended Posts

So my xml starts like this and there are about 10 ARTICLES in it.

How do I get the attibutes of ARTICLE like POSTING_DATE?

xml:

<?xml version="1.0"?>
<!DOCTYPE NEWSFEED SYSTEM "http://www.somesite/newsfeed.dtd">
<NEWSFEED>
<ARTICLE ID="435655" POSTING_DATE="16-Jun-2009" POSTING_TIME="09:00" ARCHIVE_DATE="05-Jun-2010">
<NEWS_TYPE>News</NEWS_TYPE>

PHP

<?php
$xmlRaw = file_get_contents($filename);
	$this->load->library('simplexml');
	$xmlData = $this->simplexml->xml_parse($xmlRaw);
	 ?>

AND my view file in PHP too:

<?php
foreach($xmlData['ARTICLE'] as $row)
                {
		echo $row['ARTICLE'][postING_DATE'];
		echo '<br>';
		echo '<hr>';
	}
		?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/162465-parsing-xml-attibutes/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.