Re: [Flashcoders] empty XML Attributes..

2009-08-27 Thread Kenneth Kawamoto
I think that's not exactly correct. You can use "@" to access non-existence attributes but cannot use it for filtering. With the OP example, trace(_co...@instance); ...should not generate an error but you'd get an error with: trace(_conf.(@instance == "boo")); ...so instead this should be us

Re: [Flashcoders] empty XML Attributes..

2009-08-27 Thread Steven Sacks
Unfortunately, that doesn't work. That returns something (an empty XMLList, I believe). The best way to test for attribute existence and/or if it has a value is what I wrote. Glen Pike wrote: Thanks for the answers with the length() thing - I tried out a few of those and got working thing

Re: [Flashcoders] empty XML Attributes..

2009-08-27 Thread Glen Pike
Thanks for the answers with the length() thing - I tried out a few of those and got working thing You're suggesting to write more code to do the same thing. Why should anyone write more code to do the same thing? With the above comment in mind - I was trying to do if(no...@attribute) which I t

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Steven Sacks
hasOwnProperty does not tell you whether it has a length, though. It only checks for existence. And for some reason, it looks like you modified my code when quoting me: >> if (node.hasOwnProperty("instance").length() > 0) I didn't write that code, which would error since a Boolean doesn't hav

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Taka Kojima
The Top Level XML class actually has a function, called hasOwnProperty that exists for this purpose. However, to answer your question exactly, it returns a value of undefined. This is not null or "" it is it's own return type, as this relates to XML (which by definition is an object) and objects a

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Steven Sacks
You will get runtime errors when attempting to access an attribute that isn't there. The proper way to check for existence and length of an attribute is to use the .attributes() syntax as such: if (node.attribute("instance").length() > 0) ___ Flashco

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Ian Thomas
On Wed, Aug 26, 2009 at 12:27 PM, Glen Pike wrote: > Aha, I see now - bit of a waste of code too. Yeah, I agree, it's overly verbose. > And who's bright idea was it to use length for Strings and Arrays, but > length() for XML / e4x? It's because in E4X: someNode.length Means get this node:

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Glen Pike
Aha, I see now - bit of a waste of code too. And who's bright idea was it to use length for Strings and Arrays, but length() for XML / e4x? Kenneth Kawamoto wrote: XMLList, and you can check its length(). Kenneth Kawamoto http://www.materiaprima.co.uk/ Glen Pike wrote: Hi, I am having

Re: [Flashcoders] empty XML Attributes..

2009-08-26 Thread Kenneth Kawamoto
XMLList, and you can check its length(). Kenneth Kawamoto http://www.materiaprima.co.uk/ Glen Pike wrote: Hi, I am having problems parsing some XML config files and testing for empty attributes. There is an example xml below. Problem is that I am asking for the following: _co...

[Flashcoders] empty XML Attributes..

2009-08-26 Thread Glen Pike
Hi, I am having problems parsing some XML config files and testing for empty attributes. There is an example xml below. Problem is that I am asking for the following: _co...@instance Which is returning a value, but I am not sure what type of value. Should this return null,