Page 1 of 1

php & xml parsing

Posted: Fri Oct 03, 2008 6:29 am
by blundell
Hi guys,

Been using this tutorial http://www.kirupa.com/web/xml_php_parse ... ediate.htm

all working well, however it only shows how to gather info from tags ie:

Code: Select all

 
$xml_headline_key = "*NEWS*STORY*HEADLINE"; 
 
what if i wanted only HEADLINE tags with a certain attribute i.e headline tag with id = 1:

Code: Select all

 
<?xml version="1.0"?>
<news>
<story>
<headline> Godzilla Attacks LA! </headline>
<headline id = "1"> The Monster Arrives</headline>
<description>Equipped with a Japanese Mind-control device, the giant monster has attacked important harbours along the California coast. President to take action. </description>
</story>
</news>
 
Something like this:

Code: Select all

 
$xml_headline_key = "*NEWS*STORY*HEADLINE[@id="1"]; 
 
maybe? or if not what keywords should I use in google?

Thanks guys

Re: php & xml parsing

Posted: Fri Oct 03, 2008 2:44 pm
by phppucci
Hi blundell ,

use PHP's simplexml library php.net/simplexml
specifically this method while you are reading xml input:
http://php.net/manual/en/function.simpl ... ibutes.php

Re: php & xml parsing

Posted: Fri Oct 03, 2008 4:13 pm
by youropensource
Here the available on XML parser class, check it I guess its very helpful for you :)