lets Talk Flex

Recursive XML parsing in Flex

February 25, 2009 · Leave a Comment

When I had to parse a long book.xml for CD Splitter tool I was working on recently, I had a hard time to get the xml parsed effectively and with minimum code lines.  And I was hell bent, that i’ll not bother the good old friend google for this. Finally, after few attempts I got the solution.

private function onTemplateXMLLoad(event:ResultEvent):void

{

parseTemplateXML(XML(event.result));

}

private function parseTemplateXML(objXML:XML):void

{

if(objXML != null)

{

for each(var item:XML in objXML.children())

{

// trace("hasComplexContent*** : "+item.hasComplexContent());

if(item.hasComplexContent())

{

// recursive call

parseTemplateXML(item);

}

else

{

// this is the node value you are seeking

}

}

}

}

Categories: Flex Development

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment