php & xml parsing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
blundell
Forum Newbie
Posts: 1
Joined: Fri Oct 03, 2008 6:26 am

php & xml parsing

Post 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
phppucci
Forum Newbie
Posts: 17
Joined: Fri Oct 03, 2008 2:27 pm

Re: php & xml parsing

Post 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
youropensource
Forum Commoner
Posts: 26
Joined: Tue Aug 05, 2008 11:42 am

Re: php & xml parsing

Post by youropensource »

Here the available on XML parser class, check it I guess its very helpful for you :)
Post Reply