I’m wanting to parse XML data with the EE XML parser class and came across this post. I can get the values I need out of the XML, but what if I don’t know the precise structure of the XML?
Calling a child value by number is returning different results as the XML structure changes. Ideally I’d like to be able to call like this (based on the docs example here):
$xml_obj->emails->email->subjectIs this possible? Anyone know how to do it?
Thanks.
I’ve tried a few alternatives here and so far come up with the following which allows me to target a specific tag, regardless of where abouts in the XML the tag is.
Can anyone comment on whether this is a sensible approach? Seems a little unwieldy to me…
$this->EE->load->library('xmlparser');
$xml_obj = $this->EE->xmlparser->parse_xml($result);
foreach($xml_obj->children as $key => $event)
{
foreach($event->children as $ckey => $item)
{
if($item->tag == "Start")
{
echo $item->value.'<br>';
}
}
}Any suggestions will be gratefully received 😊
Greetings,
I posted another similar thread here: http://ellislab.com/forums/viewthread/230789/
Are you still working on this and did you find a solution?
Thanks, Bob.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.