开发者

Flex XMLList Intersections, Unions, Differences

开发者 https://www.devze.com 2023-01-04 18:04 出处:网络
I don\'t think Flex supports anything like this, but I\'m new to it and thought it couldn\'t hurt to ask anyway before I go off and implement it myself. I\'m basically wondering if Flex can give me th

I don't think Flex supports anything like this, but I'm new to it and thought it couldn't hurt to ask anyway before I go off and implement it myself. I'm basically wondering if Flex can give me the union or difference or intersection of two XMLLists, as in Python's sets:

>>> a = set([1, 2, 3])
>>> b = set([3, 4, 5])
>>> b.difference(a) # set([4, 5])

I'd like to do the same thing in principle with two XML lists.

list1 = [<column name="c1" />, <column name="c2" />]
list2 = [<column name="c1" />, <column name="c2" />, <column name="c3" />]
list2.difference(list1) // [<column name="c3" />]

Native support would be awesome, so just throwing the question out开发者_JS百科 there.


I'm not too up on the XML stuff. I'm not aware of anything like that for dealing with native XML.

However, it looks like, using the syntax you describe, you actual have an array of XMLList elements. At least that is how Flex looks at your code.

The APi for arrays are more extensive thank XML or XMLList. Off the top of my head, you might be able to work something out using the splice:

http://livedocs.adobe.com/flex/3/langref/Array.html#splice()

But, when I've needed to do this sort of operation, I've used loops:

for each(var a : Object in list1){
        list2.splice(this.list2.indexOf(removeDay),1);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消