[flexcoders] e4x 101 -- Help get it through my thick skull
Hi, I'm working with webservice xml data in XML format, and the e4x is giving me a little trouble. Am I right on these points: * All e4x operations return an XMLList. I've been trying to get them to return XML, like: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) but it seems this is wrong; I should just expect an XMLList, and even if I know for sure that the result is one element long, I should just use the pertinent XML methods on the XMLList, since one-element XMLLists just pass these calls to the element. * To test for emptiness or undefined-ness, do I do this: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) if ( theNodeIWant.length() == 0 ) { // e4x query returns no results } Is length() the only way to do this, or is there a more accurate way that would return null or undefined? I get the sense that e4x is really powerful, but it's kind of different and it's been busting my balls lately. Thanks much, OK DAH
Re: [flexcoders] e4x 101 -- Help get it through my thick skull
These references helped me with e4x: http://developer.mozilla.org/presentations/xtech2005/e4x/ http://www.devx.com/webdev/Article/33393/0/page/2 Paul On Mon, Mar 24, 2008 at 8:56 AM, David Ham [EMAIL PROTECTED] wrote: Hi, I'm working with webservice xml data in XML format, and the e4x is giving me a little trouble. Am I right on these points: * All e4x operations return an XMLList. I've been trying to get them to return XML, like: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) but it seems this is wrong; I should just expect an XMLList, and even if I know for sure that the result is one element long, I should just use the pertinent XML methods on the XMLList, since one-element XMLLists just pass these calls to the element. * To test for emptiness or undefined-ness, do I do this: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) if ( theNodeIWant.length() == 0 ) { // e4x query returns no results } Is length() the only way to do this, or is there a more accurate way that would return null or undefined? I get the sense that e4x is really powerful, but it's kind of different and it's been busting my balls lately. Thanks much, OK DAH -- It is difficult to free fools from the chains they revere. - Voltaire
RE: [flexcoders] e4x 101 -- Help get it through my thick skull
To get XML from an expression, do: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo)[0]; Expressions always return an XMLList. If no records are found, then the list has zero length, so using length() is the way to do this. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of David Ham Sent: Monday, March 24, 2008 11:57 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] e4x 101 -- Help get it through my thick skull Hi, I'm working with webservice xml data in XML format, and the e4x is giving me a little trouble. Am I right on these points: * All e4x operations return an XMLList. I've been trying to get them to return XML, like: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) but it seems this is wrong; I should just expect an XMLList, and even if I know for sure that the result is one element long, I should just use the pertinent XML methods on the XMLList, since one-element XMLLists just pass these calls to the element. * To test for emptiness or undefined-ness, do I do this: var theNodeIWant : XML = myDataSet.myElement.(@someAttr == foo) if ( theNodeIWant.length() == 0 ) { // e4x query returns no results } Is length() the only way to do this, or is there a more accurate way that would return null or undefined? I get the sense that e4x is really powerful, but it's kind of different and it's been busting my balls lately. Thanks much, OK DAH