基于两个节点的 XPath 结果

XPath results based on two nodes

我 XML 有很多重复值。我想 select 具有特定部分(“sec”)和部分标记(“sec_tag”)的所有行,但我似乎无法获得正确的 XPath .

这是 XML 的一小段:

<root>
    <record>
        <sec>5</sec>
        <sec_tag>919</sec_tag>
        <nested_tag>
            <info>Info</info>
            <types>
                <type>1</type>
                <type>2</type>
                <type>3</type>
            </types>
        </nested_tag>
        <flags>00000000</flags>
    </record>

    <record>
        <sec>5</sec>
        <sec_tag>930</sec_tag>
        <nested_tag>
            <info>Info</info>
            <types>
                <type>1</type>
                <type>2</type>
                <type>3</type>
            </types>
        </nested_tag>
        <flags>00000000</flags>
    </record>
    <record>
        <sec>7</sec>
        <sec_tag>919</sec_tag>
        <nested_tag>
            <info>Info</info>
            <types>
                <type>1</type>
                <type>2</type>
                <type>3</type>
            </types>
        </nested_tag>
        <flags>00000000</flags>
    </record>
</root>

我想要具有 <sec>5</sec><sec_tag>919</sec_tag> 的节点。

我试过这样的事情:

//sec[text(), "5"] and //sec_tag[text(), "919"]

显然那不是正确的语法,我只需要找到正确的 XPath 表达式。

您可以对 return record 具有子 sec 等于 5sec_tag 等于 919 的元素使用以下 XPath 表达式:

//record[sec = 5 and sec_tag = 919]