blundell Posted October 3, 2008 Share Posted October 3, 2008 Hi guys, Been using this tutorial http://www.kirupa.com/web/xml_php_parse_intermediate.htm all working well, however it only shows how to gather info from tags ie: $xml_headline_key = "*NEWS*STORY*HEADLINE"; what if i wanted only HEADLINE tags with a certain attribute i.e headline tag with id = 1: <?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: $xml_headline_key = "*NEWS*STORY*HEADLINE[@id="1"]; maybe? or if not what keywords should I use in google? Thanks guys Link to comment https://forums.phpfreaks.com/topic/126882-php-parsing-xml/ Share on other sites More sharing options...
imzeeshan Posted October 13, 2008 Share Posted October 13, 2008 Instead , use simplexml and xpath on the xml, that will be quite simpler , http://us2.php.net/manual/en/function.simplexml-element-xpath.php let me know if you need the code for this. Link to comment https://forums.phpfreaks.com/topic/126882-php-parsing-xml/#findComment-663840 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.