function XPath(oRoot : Iv3Base; sExpression : String) : List(Iv3Base);

Class IScriptCDAManager

Select a set of objects by an XPath expression.

The first parameter is the root for the XPath expression. To start at the root of the document, pass the CDA document itself, or nil.

The second parameter is an XPath statement such as //v3:recordTarget/v3:patientRole/v3:id The namespace 'v3' is required on elements or the xpath won't work. Other namespaces that can be used in the XPath are xsi and the xml namespace itself.

The return value is a list of the objects that match the selected XPath statement. The objects may be any of the Cda, structured text or data types. Only objects that have an element can be selected. Although you can execute xpath statements that match text, attributes, comments etc, these will never be able to be matched to any matching object, and nothing will be returned.

For instance, executing the xpath above with the CDA document itself as the root will return the list of Iv3II identifiers for the patient.

Note that the XPath statements operate on the original parsed XML, and the XML is not updated as the object model itself is changed. So if you add an identifier to the list of patient identifiers in a script, then execute the XPath above, the new identifier will not be returned. Further, deleting an identifier from the list, then rerunning the XPath statement, and trying to access the deleted object will cause unpredictable results (technically, the link from the XML back to the object model is not reference counted)

Technical Note: The XPath expression is evaluated by the MSXML engine.


© Kestral Computing P/L 2000 - 2003. HL7Connect v2.00-063 generated on 30-Nov 2015.
Keywords: XPath