Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

xpath expression: find value of element based on other element

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading