all groups > dotnet xml > august 2005 >
You're in the

dotnet xml

group:

xpath question


xpath question Jeremy Chapman
8/19/2005 2:26:02 PM
dotnet xml:
I have the following xpath statement which returns the value in the
<IHA_PL_0_Location> node of the schema below. My problem is that the
Root node may not always be ADT_A02_21_GLO_DEF, it could be
ADT_A04_21_GLO_DEF or something else. How can I write an xpath that is
independant of the root node?

/*[local-name()='ADT_A02_21_GLO_DEF' and
namespace-uri()='http://mycompany.ca/test/HL7/2X']/*[local-name()='PV1_PatientVisit'
and namespace-uri()='']/*[local-name()='PV1_3_AssignedPatientLocation' and
namespace-uri()='']/*[local-name()='IHA_PL_0_Location' and
namespace-uri()='']

<ns0:ADT_A02_21_GLO_DEF xmlns:ns0="http://mycompany.ca/test/HL7/2X">
<PV1_PatientVisit>
<PV1.1_SetIdPatientVisit>PV1.1_SetIdPatientVisit_0</PV1.1_SetIdPatientVisit>
<PV1.2_PatientClass>PV1.2_PatientClass_0</PV1.2_PatientClass>
<PV1_3_AssignedPatientLocation>
<IHA_PL_0_Location>IHA_PL_0_Location_0</IHA_PL_0_Location>
<IHA_PL.1_NotUsed>IHA_PL.1_NotUsed_0</IHA_PL.1_NotUsed>
<IHA_PL.2_NotUsed>IHA_PL.2_NotUsed_0</IHA_PL.2_NotUsed>
</PV1_3_AssignedPatientLocation>
</PV1_PatientVisit>
</ns0:ADT_A02_21_GLO_DEF>

Re: xpath question Dimitre Novatchev
8/20/2005 12:00:00 AM
Use:

/*/PV1_PatientVisit/PV1_3_AssignedPatientLocation/IHA_PL_0_Location

or even:

/*/*/*/IHA_PL_0_Location

if the latter is unambiguous and will select the same as the former
expression.


Cheers,
Dimitre Novatchev

[quoted text, click to view]

AddThis Social Bookmark Button