基于多PARAMS过滤XML - Flex的 [英] Filtering XML based on multiple params - Flex

查看:156
本文介绍了基于多PARAMS过滤XML - Flex的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据我必须为输入多个参数来过滤XML。

I am trying to filter an XML based on multiple parameters that I have as an input.

我试图找出具有匹配的记录父节点,以便我可以过滤出来和处理。

I am trying to identify the parent nodes which have the matching records so that I can filter them out and process.

<A>
    <B1>
        <C1>
            <D1>111</D1>
            <E1>111</E1>
            <F1>
                <G1>111</G1>
                <H1>
                    <I1>111</I1>
                    <J1>111</J1>
                </H1>
            </F1>
        </C1>
    </B1>
    <B1>
        <C1>
            <D1>222</D1>
            <E1>333</E1>
            <F1>
                <G1>222</G1>
                <H1>
                    <I1>222</I1>
                    <J1>222</J1>
                </H1>
            </F1>
        </C1>
    </B1>
    <B1>
        <C1>
            <D1>333</D1>
            <E1>333</E1>
            <F1>
                <G1>333</G1>
                <H1>
                    <I1>333</I1>
                    <J1>333</J1>
                </H1>
            </F1>
        </C1>
    </B1>
</A>

可以说,我需要匹配的节点D1和E1和I1,但如果所有的参数a'和'比赛,我需要有节点直接从&LT; B1&GT; 的结果。

<B1>
    <C1>
        <D1>222</D1>
        <E1>333</E1>
        <F1>
            <G1>222</G1>
            <H1>
                <I1>222</I1>
                <J1>222</J1>
            </H1>
        </F1>
    </C1>
</B1>

我想USNG以下组合,以获取数据:

I am trying usng the below combination to get the data:

xml..*.((hasOwnProperty("D1") && D1 == "222")&&hasOwnProperty("E1") && D1 == "333"))

但认为有一些差距。有人可以填写并告诉我,我要去哪里错了,还是有更好的方法来过滤XML? 此外,有没有一些东西,在的filterFunction(集合)可以帮帮忙?

But think there is some gap. Can someone fill in and tell me where am I going wrong or is there a better approach to filter an XML? Also, is there something which the filterFunction (collections) can help out with?

推荐答案

您可以使用 .. 运营商,或致电其equvalent 后代( )来获得符合标准的,无论他们在哪里层次结构中的所有子节点的XMLList。然后,使用 XML(标准),仅选择也括号内匹配前pression节点:

You can use the .. operator, or call its equvalentdescendants() to get an XMLList of all sub nodes that match your criteria, regardless of where they are in the hierarchy. Then, using xml.( criteria ), select only the nodes that also match the expression within the parentheses:

var result:XMLList = xml..B1.(
   ( descendants ("D1") == "222" ) && 
   ( descendants ("E1") == "333" ) && 
   ( descendants ("I1").length() > 0 )  // or any other expression
   );

这篇关于基于多PARAMS过滤XML - Flex的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆