Tuesday, October 30, 2007

XPath: Select a Node Value iff a sibling node has value X

I needed to extract an MRN from an XML patient record. This record contains multiple PID.3 tags each of which contain inside a number (inside CX.1) and a text description of what this number is (CX.5). For example, 514149220 and SSN. Here's how I did it:

*//PID.3/CX.1[following-sibling::CX.5/text()="MRN"]/text()

No comments:

Labels

Blog Archive

Contributors