[flexcoders] Re: e4x help
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, wrote: > > I must be missing something simple here. I'm reading in XML that looks like > this: > > > > > > > Attr_1 > > > Attr_2 > > > Attr_3 > > > > > I'm trying to get all 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 >
RE: [flexcoders] Re: E4X Help
You also need to change = to == in your E4X filter. A working example is below. - Gordon http://www.adobe.com/2006/mxml";> 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, > > > > > > ... > > > > > ... > > ... > > > 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/
[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, > > > > > > ... > > > > > ... > > ... > > > 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/