Try:

 trace("t3=" + opt.toXmlString());

(I think it's tracing the actual value of each node, which is "")

The toXmlString() value is a much bigger help when you're testing/debugging e4x 
code.


-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of peter 
eakle
Sent: 01 April 2008 02:21
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Having trouble with e4x and "for each" -- getting empty 
XML value inside loop

Inside the "for each" loop I am getting a value that is empty. Here is
a sample program that illustrates the problem:

private function xmlTesting() : void
{
var myXml:XML = new XML("<root><commands> \
<command name='c1' > \
<options> \
<option name='o1'/> \
<option name='o2'/> \
</options> \
</command> \
<command name='c2' > \
<options> \
<option name='o3'/> \
<option name='o4'/> \
<option name='o5' /> \
</options> \
</command> \
</commands> \
</root>");

var myXml2:XMLList = myXml.commands.command.(@name=="c2");

trace("t1=" + myXml2[0].options);
trace ("t2=" + myXml2[0].options.option);

for each (var opt:XML in myXml2[0].options.option)
{
trace("t3=" + opt);
}
}

Here is the output I see in the trace window:

t1=<options>
<option name="o3"/>
<option name="o4"/>
<option name="o5"/>
</options>
t2=<option name="o3"/>
<option name="o4"/>
<option name="o5"/>
t3=
t3=
t3=

I don't understand why my value of "opt" in the "for each" loop shows
up as empty in the trace (t3). I must be missing something. Any help
appreciated. Thanks.
 

______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in 
England and Wales with registration No. 02622298 and registered office: 4th 
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT 
registration No. 648874577.

This e-mail is confidential and may be privileged. It may be read, copied and 
used only by the intended recipient. If you have received it in error, please 
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 
1010. Please then delete the e-mail and do not disclose its contents to any 
person.
This email has been scanned for Primal Pictures by the MessageLabs Email 
Security System.
______________________________________________________________________

Reply via email to