We help IT Professionals succeed at work.
Get Started

Help Trying to Iterate XML File in FLEX

chuela asked
Last Modified: 2013-11-11
I don't know what I am doing wrong
I need to interate through each node of an XML document from a FLEX Module but it does not seem to work

The XML is loaded at the parent app
Here's the ActionsScript
And the XML as well
public var poll_xml:XML;
			public function init():void{
				poll_xml = new XML(parentApplication.pollresults);
				// Iterate through Each Poll Page
            	for each (var question:XML in poll_xml.*) {
            		for each (var item:XML in question.*){
            			var lbl:Label;
						if (item.name()=="text"){
							lbl = new Label;
							lbl.htmlText = item + " Type:" + item.@type;;
						if (item.name()=="answer"){
							lbl = new Label;
							lbl.htmlText = "Answer : " + item;
							if (item.@value!=null) lbl.htmlText += " Valor : " + item.@value;


The XML :

<?xml version="1.0" encoding="utf-8"?>
<poll id="2" space="200">
		<text number="false" type="text">El Nombre de la pregunta</text>
		<answer>UNa respuesta</answer>
		<answer>Otra respuesta en un repeater</answer>
		<answer>Otra por que no</answer>
		<answer>Otra MAs</answer>
		<text type="bars">El Nombre de la pregunta 2 </text>
		<answer value="120">Total Pregunta esta</answer>
		<answer value="200">Total Pregunta esta otra</answer>
		<answer value="30">Y esta</answer>
		<text type="pie">El Nombre de la pregunta 3</text>
		<answer value="80">Total Pregunta esta</answer>
		<answer value="50">Total Pregunta esta otra</answer>
		<answer value="110">Y esta</answer>

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE