Re: SimpleXML or DOMDocument help

From: Date: Wed, 09 Dec 2009 20:46:39 +0000
Subject: Re: SimpleXML or DOMDocument help
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-300348@lists.php.net to get a copy of this message
Shawn McKenzie wrote: > Shawn McKenzie wrote: >> Please keep this on list. >> >> The URI for the namespace is important. Something like (not tested): >> >> | ||// use URI for Query namespace| >> | foreach >> ($xml->children('http://www.example.com/something') as >> $Query) { >> echo $Query->Where; >> } >> || >> | >> Michael Alaimo wrote: >>>> What's the entire XML document? You need a xmlns declaration as Query >>>> is a namespace. >>>> >>> The document is valid XML. xml_parse_into_struct returns an array with >>> all of the values. Its just so much work to get it to work. >>> >>> SimpleXML wont let me access $xml->Query->{Query:Where}. for example >>> >>> >>>> -- >>>> Thanks! >>>> -Shawn >>>> http://www.spidean.com > > Wow, that came out with some weird pipes in it: > > // use URI for Query namespace > foreach > ($xml->children('http://www.example.com/something') as > $Query) { > echo $Query->Where; > } > I guess you could also use (not tested): $ns = $xml->getNamespaces(true); foreach ($xml->children($ns['Query']) as $Query) { echo $Query->Where; } Maybe look at the xpath() method, I don't know anything about it. -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#300348) next »