基于PARAMS动态XML过滤 [英] Dynamic XML filtering based on params
问题描述
跟进<一个问题href="http://stackoverflow.com/questions/9183734/filtering-xml-based-on-multiple-params-flex">Filtering基于多PARAMS XML - Flex的
我试图动态创建查询部分,使PARAMS和按键接管建设标准的一部分。只是为了说明:
I was trying to create the Query part dynamically so that params and the keys take over for building the criteria part. Just to show:
//building a dynamic query like this
var q1:String = "descendants (\"E1" ) == \"111\" )";
Alert.show("Query>>"+q1.toString()); // Output: descendants ("E1" ) == "111"
var r2:XMLList = xmlData..*.(descendants ("E1" ) == "111"); //returns correct result
var r1:XMLList = xmlData..*.(q1.toString()); // weird response,
// doesn't filter out anything
在这里<一个注释href="http://stackoverflow.com/questions/9183734/filtering-xml-based-on-multiple-params-flex#comment11557459_9184132">Filtering基于多PARAMS XML - Flex的说,括号内的前pression不应该是一个字符串。答应了。
A comment here Filtering XML based on multiple params - Flex says that the expression inside the parentheses should not be a string. Agreed.
那么,还有没有其他的方法来筛选出多个参数中的XML,而不是使用
的后裔()
,目前没有工作,因为我们是动态生成的搜索查询的基础上,PARAMS搜索?
So, is there any other approach to filter out multiple parameters in XML than to use the
descendants()
, which currently is not working out because we are building the search query dynamically, based on the params searched?
任何指针/想法将有很大的帮助。
Any pointers/ideas would be of great help.
推荐答案
如何做过滤在一个循环?
How about doing the filtering in a loop?
var filters : Array = [ { key : "E1", value : "333" }, { key : "D1", value : "333" } ];
var searchItem : XMLList = xmlData.*;
for each (var filter:Object in filters)
searchItem = searchItem.( descendants ( filter.key ) == filter.value);
trace (searchItem);
这篇关于基于PARAMS动态XML过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!