对于附加的XML,我想使用正则表达式[A-Z] [A-Z] \ d {5} | [A-Z] \ d {6}来匹配字符串SZ9421。
此字符串可以位于OBR.5中的任何节点内。有没有简单的方法将其提取到xml或html或pdf视图?
<OBX.5>
Swee T Tan<escape V=".br"/>Client<escape V=".br"/>Number<escape V=".br"/>SZ9421<escape V=".br"/>Full Name:<escape V=".br"/>XX, Robert (Mr)<escape V=".br"/>Address:<escape V=".br"/>XX XX Street<escape V=".br"/>XXX<escape V=".br"/>LOWER HUTT 5011<escape V=".br"/>Date of Birth:<escape V=".br"/>15.03.1987<escape V=".br"/>Telephone:<escape V=".br"/>(h) 938 2684<escape V=".br"/>(m) 027 632 4590<escape V=".br"/>NHI Number:<escape V=".br"/>JAP5065<escape V=".br"/>Date of Injury:<escape V=".br"/>16.09.2011<escape V=".br"/>Referring Provider:<escape V=".br"/>Dr Erich Kusel<escape V=".br"/>
<escape V=".br"/>History, Examination and Diagnosis<escape V=".br"/>Type of Assessment<escape V=".br"/>CS100 - Simple<escape V=".br"/>History of the current condition:<escape V=".br"/>This patient sustained a laceration on the radial aspect of the proximal phalanx of the left middle finger about 3 weeks agop while cooking. He lost sensation distal to this on the radial side of the middle finger immediately. There has been no recovery of this since then.<escape V=".br"/>Causal Medical Link Between Proposed Treatment & Covered Injury:<escape V=".br"/>Yes, as described herein.<escape V=".br"/>Relevant Pre-existing Factors:<escape V=".br"/>Nil.<escape V=".br"/>Clinical Examination:<escape V=".br"/>Clinical examination shows a healed scar on he radial side of the left middle finger. There is complete loss of sensation on the radial border of that finger distal to the scar. He has a full range of motion in that finger.<escape V=".br"/>Diagnostic Tests & Imaging:<escape V=".br"/>Nil.<escape V=".br"/>Specific Diagnosis:<escape V=".br"/>Transection of radial digital nerve left middle finger.<escape V=".br"/>
<escape V=".br"/>
</OBX.5>
XSD
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="OBX.5">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element ref="escape" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="escape">
<xs:complexType>
<xs:attribute name="V" use="required" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:schema>
答案 0 :(得分:1)
为什么不使用Xpath而不是诉诸正则表达式?
假设SZ9421
前面有一个值为Number
的文本节点,然后是一个链接escape
元素:
修改
根据@ Tomalek的评论,可以通过text()[1]
进一步约束来确保更好地指定,以确保这些必须 相邻text()
的每一方。
//OBX.5/escape[preceding-sibling::text()[1]='Number']/following-sibling::text()[1]