xpath表达式:根据其他元素查找元素的值

发布于 2025-01-15 12:11:40 字数 1774 浏览 0 评论 0原文

如果标题的值是“这是一个标题”,我想找到演示者的值

<AXFRoot>
    <MAObject type="default" mdclass="PROGRAM">
        <GUID dmname="">ID00001</GUID>
    </MAObject>
    <MVAttribute type="RUNDOWN" index="0" attribute="RUNDOWN" mdclass="PROGRAM" objectid="ID00001">
        <Meta name="TITLE" format="string">This is a title</Meta>
        <Meta name="AIRDATE" format="string">20201001194131</Meta>
        <Meta name="PAGE_NUMBER" format="string">01</Meta>
        <Meta name="PRESENTER" format="string">abcdef</Meta>
        <Meta name="AUDIO_TIME" format="string">0</Meta>
        <Meta name="TOTAL_TIME" format="string">0</Meta>
        <Meta name="ARCHIVE" format="string">0</Meta>
        <Meta name="MOS_TITLE" format="string" />
    </MVAttribute>
    <MVAttribute type="RUNDOWN" index="1" attribute="RUNDOWN" mdclass="PROGRAM" objectid="ID00001">
        <Meta name="TITLE" format="string">This is another title</Meta>
        <Meta name="AIRDATE" format="string">20201001194131</Meta>
        <Meta name="PAGE_NUMBER" format="string">01</Meta>
        <Meta name="PRESENTER" format="string">ghijkl</Meta>
        <Meta name="AUDIO_TIME" format="string">0</Meta>
        <Meta name="TOTAL_TIME" format="string">0</Meta>
        <Meta name="ARCHIVE" format="string">0</Meta>
        <Meta name="MOS_TITLE" format="string" />
    </MVAttribute>
</AXFRoot>

到目前为止我得到了,

//AXFRoot/MVAttribute[@type='RUNDOWN']/Meta[@name='TITLE' and text()='This is a title']

但这只给了我标题元素,而不是演示者的值。我需要添加什么?

I want to find the value of the presenter if the value of the title is 'This is a title'

<AXFRoot>
    <MAObject type="default" mdclass="PROGRAM">
        <GUID dmname="">ID00001</GUID>
    </MAObject>
    <MVAttribute type="RUNDOWN" index="0" attribute="RUNDOWN" mdclass="PROGRAM" objectid="ID00001">
        <Meta name="TITLE" format="string">This is a title</Meta>
        <Meta name="AIRDATE" format="string">20201001194131</Meta>
        <Meta name="PAGE_NUMBER" format="string">01</Meta>
        <Meta name="PRESENTER" format="string">abcdef</Meta>
        <Meta name="AUDIO_TIME" format="string">0</Meta>
        <Meta name="TOTAL_TIME" format="string">0</Meta>
        <Meta name="ARCHIVE" format="string">0</Meta>
        <Meta name="MOS_TITLE" format="string" />
    </MVAttribute>
    <MVAttribute type="RUNDOWN" index="1" attribute="RUNDOWN" mdclass="PROGRAM" objectid="ID00001">
        <Meta name="TITLE" format="string">This is another title</Meta>
        <Meta name="AIRDATE" format="string">20201001194131</Meta>
        <Meta name="PAGE_NUMBER" format="string">01</Meta>
        <Meta name="PRESENTER" format="string">ghijkl</Meta>
        <Meta name="AUDIO_TIME" format="string">0</Meta>
        <Meta name="TOTAL_TIME" format="string">0</Meta>
        <Meta name="ARCHIVE" format="string">0</Meta>
        <Meta name="MOS_TITLE" format="string" />
    </MVAttribute>
</AXFRoot>

So far I got

//AXFRoot/MVAttribute[@type='RUNDOWN']/Meta[@name='TITLE' and text()='This is a title']

but this only gives me the title element, not the value of the presenter. What do I need to add?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝颜夕 2025-01-22 12:11:41

你就快到了:

//AXFRoot/MVAttribute[@type='RUNDOWN']
                     /Meta[@name='TITLE' and text()='This is a title']
                     /../Meta[@name='PRESENTER']

或者

//AXFRoot/MVAttribute[@type='RUNDOWN']
                     [Meta[@name='TITLE' and text()='This is a title']]
                     /Meta[@name='PRESENTER']

You were almost there:

//AXFRoot/MVAttribute[@type='RUNDOWN']
                     /Meta[@name='TITLE' and text()='This is a title']
                     /../Meta[@name='PRESENTER']

or

//AXFRoot/MVAttribute[@type='RUNDOWN']
                     [Meta[@name='TITLE' and text()='This is a title']]
                     /Meta[@name='PRESENTER']
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文