[flexcoders] Re: e4x help

2011-09-22 Thread DP
You're probably getting an e4x error on the first empty node (because Attribute 
doesn't exist there).

Try to avoid this issue by using the hasOwnAttribute function to make sure 
that Attribute actually exists in that node.  This probably isn't it, but 
it's close:

xmlRoot..(hasOwnAttribute(Attribute))

I'm not sure the above will work because we're not returning a specific level, 
but hopefully you get the idea.  Use the following URL for a great explanation 
of Advanced E4X:

http://joshblog.net/2007/06/29/getting-advanced-with-e4x/

Hope that helps...

--- In flexcoders@yahoogroups.com, michael_regert@... wrote:

 I must be missing something simple here.  I'm reading in XML that looks like 
 this:
 
 ?xml version=1.0 encoding=UTF-8?
 REGISTRY
   REGISTRY_DECLARATION/
   REGISTRY_ENTRIES
 Attribute
   AttributeNameAttr_1/AttributeName
 /Attribute
 Attribute
   AttributeNameAttr_2/AttributeName
 /Attribute
 Attribute
   AttributeNameAttr_3/AttributeName
 /Attribute
   /REGISTRY_ENTRIES
 /REGISTRY
 
 I'm trying to get all Atribute nodes using the .. operator, but it always 
 returns 0, even though xmlRoot looks fine.
 
 protected function xmlService_resultHandler(event:ResultEvent):void
 {
   if (event != null  event.result != null  event.result is XML) {
 var xmlRoot:XML = event.result as XML;
 if (xmlRoot  xmlRoot.length()  0) {
   var lst:XMLList = xmlRoot..Attribute;
   trace(lst length =  + lst.length());
 }
   }
 }
 
 
 Michael





[flexcoders] Re: E4X Help

2006-10-20 Thread Michael Labriola

Tangent,

Remove the {} from around selected :

var counties:XMLList = _myXml.state.(@label=selected).county;

Mike

--- In flexcoders@yahoogroups.com, Tan [EMAIL PROTECTED] wrote:

 I try writing two comboboxes to facilitate selection of the
following XML,
 
 data
   state label=Texas data=Texas
   county label=Jones data=123 /
   county label=Taylor data=124 /
   ...
   /state
   state label=Virginia data=Virginia
   county label=Alexandria data=223 /
   county label=Arlington data=224 /
   ...
   /state
   ...
 
 
 The first combo box is named _combo1 that is populated by state
data, and I
 want to get an XML or XMLList of the counties using AS3, I wonder
whether I
 can write it in E4X syntax that looks somewhat like
 
   var selected:String = _combo1.selectedItem.toString();
   var counties:XMLList = _myXml.state.(@label = {selected}).county;
 
 I get a compiler error for the last line, and I have searched
through some
 E4X samples, didn't seem to find any help.  Any advice?
 
 Thanks!
 
 - Tangent
 
 P.S.  Or should I use XmlViewCollection, Descriptor or things like that?






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 



RE: [flexcoders] Re: E4X Help

2006-10-20 Thread Gordon Smith
You also need to change = to == in your E4X filter. A working example is below.

- Gordon

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml;

mx:Script
![CDATA[

private var stateCountyData:XML =
data
state label=Texas data=Texas
county label=Jones 
data=123 /
county label=Taylor 
data=124 /
/state
state label=Virginia data=Virginia
county label=Alexandria 
data=223 /
county label=Arlington 
data=224 /
/state
/data;

private function setStates():void
{
stateCombo.dataProvider = stateCountyData.state;
}

private function setCounties():void
{
countyCombo.dataProvider = 
stateCountyData.state.(@label == stateCombo.selectedLabel).county;
}

]]
/mx:Script

mx:ComboBox id=stateCombo labelField=@label width=200
 creationComplete=setStates(); setCounties()
 change=setCounties()/
 
mx:ComboBox id=countyCombo labelField=@label width=200/

/mx:Application


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Michael 
Labriola
Sent: Friday, October 20, 2006 11:07 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: E4X Help


Tangent,

Remove the {} from around selected :

var counties:XMLList = _myXml.state.(@label=selected).county;

Mike

--- In flexcoders@yahoogroups.com, Tan [EMAIL PROTECTED] wrote:

 I try writing two comboboxes to facilitate selection of the
following XML,
 
 data
 state label=Texas data=Texas
 county label=Jones data=123 /
 county label=Taylor data=124 /
 ...
 /state
 state label=Virginia data=Virginia
 county label=Alexandria data=223 /
 county label=Arlington data=224 /
 ...
 /state
 ...
 
 
 The first combo box is named _combo1 that is populated by state
data, and I
 want to get an XML or XMLList of the counties using AS3, I wonder
whether I
 can write it in E4X syntax that looks somewhat like
 
 var selected:String = _combo1.selectedItem.toString();
 var counties:XMLList = _myXml.state.(@label = {selected}).county;
 
 I get a compiler error for the last line, and I have searched
through some
 E4X samples, didn't seem to find any help. Any advice?
 
 Thanks!
 
 - Tangent
 
 P.S. Or should I use XmlViewCollection, Descriptor or things like that?

 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* Your email settings:
Individual Email | Traditional

* To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)

* To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/