[phpXML] Re: [phpXML] Re: [phpXML] Before 1N6
Brought to you by:
bs_php,
nigelswinson
From: <nig...@us...> - 2001-10-08 15:57:15
|
> Or if you don't have enough time, just tell me what is now the right > version of this code that worked with xml.php/1N4 : > > <buddy_list> > <buddy id="1"> > <lastname>Doe</lastname> > <firstname>John</firstname> > <isniceguy>Yes</isniceguy> > </buddy> > </buddy_list> > > $myatrributesarray = array(); > $listofmybuddies = $xml->evaluate('/buddy_list/buddy'); > foreach ( $listofmybuddies as $buddy ) > { > $myatrributesarray = $xml->get_attributes($buddy); > $id = $myatrributesarray['id'] > $firstname = $xml->get_attributes($buddy ."/firstname[1]"); > $lastname = $xml->get_content($buddy ."/lastname[1]"); > $isniceguy = $xml->get_content($buddy ."/isniceguy[1]"); > } Along the lines of: $myatrributesarray = array(); $listofmybuddies = $xml->evaluate('/buddy_list/buddy'); foreach ( $listofmybuddies as $buddy ) { $myatrributesarray = $xml->getAttributes($buddy); $id = $myatrributesarray['id']; // Well this is what you wrote, but for your XML fragment this will return a // null array.... $firstname = $xml->getAttributes($buddy ."/firstname[1]"); $lastname = $xml->getData($buddy ."/lastname[1]"); $isniceguy = $xml->getData($buddy ."/isniceguy[1]"); // Or: $lastname = $xml->substringData($buddy ."/lastname[1]"); $isniceguy = $xml->substringData($buddy ."/isniceguy[1]"); // Or $lastname = implode('', $xml->getDataParts($buddy ."/lastname[1]")); $isniceguy = implode('',$xml->getDataParts($buddy ."/isniceguy[1]")); } Should all be in the online documentation, ie what function replaces what: http://www.carrubbers.org/scripts/php/xmlphp/doc/PhpXmlDocumentation.php Nigel -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |