leewad Posted December 5, 2006 Share Posted December 5, 2006 Hi Im trying to get the values out of XML but the nodes are same name so i cannot use $description = GetElementByName($Nodes[$i], "<description>", "</description>"); the XML is:<description>picture1</description><description>picture2</description><description>picture3</description><description>picture4</description>How can I get the value in an array?i.e$description1= "picture1";$description2= "picture2";$description3= "picture3";$description4= "picture4";Many thanks in advance Link to comment https://forums.phpfreaks.com/topic/29501-xml-parser-using-php/ Share on other sites More sharing options...
genericnumber1 Posted December 5, 2006 Share Posted December 5, 2006 GetElementByName() isn't a PHP function that I know of o.othe EASIEST way that I know of... would be something like this...[code=php:0]<?php$descriptions = <<<EOT<descriptions><description>picture1</description><description>picture2</description><description>picture3</description><description>picture4</description></descriptions>EOT;$descriptions = simplexml_load_string($descriptions);foreach ($descriptions->description as $description) { echo $description;}?>[/code]There is no easy way I can think of you being able to loop through the "<description>" elements without having a parent element. (using XML functions that is, it's easy to do it with just manipulating the text with non-XML functions)Alternatively you could create a pretty big parser for such a little application... for more info on that you could start here... http://www.php.net/xml_parser_createSorry I couldn't give you any more info! gl Link to comment https://forums.phpfreaks.com/topic/29501-xml-parser-using-php/#findComment-135376 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.