For this (and that!) xpath is your friend. See this example at http://php.net/manual/en/simplexmlelement.xpath.php $string = <<<XML <a> <b> <c>text</c> <c>stuff</c> </b> <d> <c>code</c> </d> </a> XML; $xml = new SimpleXMLElement($string); /* Search for <a><b><c> */ $result = $xml->xpath('/a/b/c'); while(list( , $node) = each($result)) { echo '/a/b/c: ',$node,"\n"; } /* Relative paths also work... */ $result = $xml->xpath('b/c'); while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; } Victor Kane http://awebfactory.com.ar http://projectflowandtracker.com On Thu, Mar 24, 2011 at 10:09 PM, <jeff@ayendesigns.com> wrote: When all else fails, and #xml, ##php and #drupal-support come up empty...ask the folks who actually code :) I have an xml structure that has <this> <that parm1="a" parm2="b" parm3="c">red</that> <that parm1="e" parm2="f" parm3="d">blue</that> </this> I've tried simplexml and a few third-party scripts, one that loads the xml into an associative array rather than an object, and nothing lets me get at 'red' or 'blue'. When I use dsm() on the results, for example, in the case of the object with simplexml I get only one 'that' and do not get its contents. When I use the script that creates the array, I get both that's, and all their parms as elements, but not the colors. I'm curious what else people are using. Jeff -- I am a non sequitur. Beware, the contents were packaged where peanuts are processed. Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com Drupal: j. ayen green (367108) IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns | Facebook: ayendesigns | Twitter: @ayendesigns Ayen Designs is the computer services division of On Thu, Mar 24, 2011 at 10:09 PM, <jeff@ayendesigns.com> wrote:
When all else fails, and #xml, ##php and #drupal-support come up empty...ask the folks who actually code :)
I have an xml structure that has
<this> <that parm1="a" parm2="b" parm3="c">red</that> <that parm1="e" parm2="f" parm3="d">blue</that> </this>
I've tried simplexml and a few third-party scripts, one that loads the xml into an associative array rather than an object, and nothing lets me get at 'red' or 'blue'. When I use dsm() on the results, for example, in the case of the object with simplexml I get only one 'that' and do not get its contents. When I use the script that creates the array, I get both that's, and all their parms as elements, but not the colors.
I'm curious what else people are using.
Jeff -- *I am a non sequitur. Beware, the contents were packaged where peanuts are processed.*
Ayen Designs 388 Bullsboro Drive #105 · Newnan, Georgia 30263 404-271-9734 Web:ayendesigns.com Blog: theAccidentalCoder.com <http://theaccidentalcoder.com/> Drupal: j. ayen green <http://drupal.org/user/367108> (367108) IRQ: j_ayen_green IM (Yahoo) baalwww (MSN) baalwww@yahoo.com Skype: ayendesigns | Facebook: ayendesigns | Twitter: @ayendesigns
Ayen Designs is the computer services division of