XPath - get parent node

Posted by chris.shi on Stack Overflow See other posts from Stack Overflow or by chris.shi
Published on 2012-12-14T16:20:46Z Indexed on 2012/12/14 17:03 UTC
Read the original article Hit count: 287

Filed under:
|
//* [ local-name()='component' and namespace-uri()='urn:hl7-org:v3'   ] 

using thispath ,I can get a node like this:

<component xmlns="urn:hl7-org:v3">
<structuredBody>

<component>
    <section>
    <code code="10164-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
    <title>History of Present Illness</title>
    <text>
    </text>
    </section>
</component>


    <component>
    ......
        </component>


    <component>
    ......
    </component>
<structuredBody/>
<component/>

in order to get the node as below:

<component>
        <section>
        <code code="10164-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
        <title>History of Present Illness</title>
        <text>
        </text>
        </section>
    </component>

I change the path to :

//* [ local-name()='component' and namespace-uri()='urn:hl7-org:v3'  and  position()=1] 

but ,how can I get the same result by using [code="10164-2"] as a qualification.

( I do not know how to describe this question ,as a result ,the title of this question is a little simple ,sorry .)

thanks

© Stack Overflow or respective owner

Related posts about xpath

Related posts about xpath-2.0