Hi,
Here is an XML:
<nodes>
<node id="0" a="hello" b="this"/>
<node id="1" c="is" d="a" e="test"/>
</nodes>
Is there a way, using E4X Filtering to find the node(s) who has an attribute with "this" as value ?
Hi,
Here is an XML:
<nodes>
<node id="0" a="hello" b="this"/>
<node id="1" c="is" d="a" e="test"/>
</nodes>
Is there a way, using E4X Filtering to find the node(s) who has an attribute with "this" as value ?
myXML.node.(@b == "this")
The above should work, though if you mean any attribute, then I think you have look through it youself. Though you could do it with regex then.
You could try with something like this:
xml.node.( find(attributes(), "this") );
function find(atts:XMLList, value:String):Boolean {
for each(var a in atts) if(a==value) return true;
return false;
}
But I personally think that a simple loop to assemble a new XMLList is easier to understand, hence a better code practice... Complex E4X and RegEx are very hard to follow, and when they don't present considerable better performance than simpler solutions (i.e. loops), I don't think they should be used...