I was doing some tests here using code from Jason Merril (see previous
thread today), and something has brought my attention.
Here's the xml:
var test:XML = <data>
<topics>
<topic title="Coldplays New Album" />
<topic title="The Dark Knight" />
<topic title="Arrested Development: The Movie" />
</topics>
</data>;
I tried two cases:
var re:RegExp = new RegExp("^Cold");
var xmlListSearch:XMLList = test..*.topic.(
re.test(attribute('title').toString()) );
and:
var re:RegExp = new RegExp("^Cold");
var xmlListSearch:XMLList = test..*.topic.(
!re.test(attribute('title').toString()) );
// this one just negates the RegExp.test() inside topic.() so I should get
the nodes NOT matching
Well, when I run the first case, I get an empty XMLList, so I was thinking
"well, that doesn't work".
However, when I run the second test, I get the XMLList with all elements
EXCEPT the one filtered out, so it actually works!
But what is going on that when the regexp returns true, my XMLList is empty?
This seems a bit strange.
Note: after writing all this, I tried something else:
// this does not work
var xmlListSearch:XMLList = test..*.topic.( attribute('title').toString() ==
"The Dark Knight" );
// this DO work
var xmlListSearch:XMLList = test..*.topic.( attribute('title').toString() !=
"The Dark Knight" );
Now, THAT's bizarre!
(BTW, I'm quite new to this E4X thing, I'm more of a XPath guy, so bear with
me if I did something completely wrong ;)
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders