Xml 将属性值与集合匹配的XPath查询

Xml 将属性值与集合匹配的XPath查询,xml,xpath,Xml,Xpath,例如,如果我有下面的xml <root> <actors> <actor id="1">Christian Bale</actor> <actor id="2">Liam Neeson</actor> <actor id="3">Michael Caine</actor> <actor id="4">Sylvester

例如,如果我有下面的xml

<root>
    <actors>
        <actor id="1">Christian Bale</actor>
        <actor id="2">Liam Neeson</actor>
        <actor id="3">Michael Caine</actor>
        <actor id="4">Sylvester Stallone</actor>
    </actors>
</root>

克里斯蒂安·贝尔
利亚姆·尼森
迈克尔·凯恩
西尔维斯特·史泰龙
以及具有值(1,2,4)的过滤器列表。如何编写一个XPath查询来选择具有id且值在筛选器列表中的所有参与者


我正在寻找一种将属性值与列表匹配的方法。我知道,如果您使用的是XPath2.0,您可以使用

/root/actors/actor[@id=(1, 2, 4)]

显然,我无法搜索,该链接回答了我的问题。您是否将所有
@id
存储在变量中或在任何应用程序中逐个传递?@Andersson的答案运行良好。甚至比@Micha Wiedenmann的评论更好