XPath表达式?

时间:2013-04-08 14:12:17

标签: xpath

<?xml version="1.0" encoding="UTF-8"?>
<Patients>
  <patientRole>
    <id extension="996-756-495" root="2.16.840.1.113883.19.5"/>
    <id extension="775-756-495" root="2.16.840.1.113883.14.6"/>
    <patient>
      <name>
        <given>Henry</given>
        <family>Levin</family>
      </name>
      <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
      <birthTime value="19320924"/>
    </patient>
    <providerOrganization>
      <id root="2.16.840.1.113883.19.5"/>
      <name>Good Health Clinic</name>
    </providerOrganization>
    <admissionTime value="2012030111:32"/>
  </patientRole>
  <patientRole>
    <id extension="65" root="2.16.840.1.113883.3.933"/>
    <patient>
      <name>
        <given>Paul</given>
        <family>Pappel</family>
      </name>
      <administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
      <birthTime value="19551217"/>
    </patient>
    <providerOrganization>
      <id extension="84756-11241-283-OPTD-3322" root="1.2.3.4.5.6.1.8.9.0"/>
      <name> Dr.med. Hans Topp-Glucklich</name>
    </providerOrganization>
    <admissionTime value="201201152200"/>
  </patientRole>
  <patientRole>
    <id extension="800001" root="2.16.840.1.113883.19.5"/>
    <patient>
      <name>
        <given>JEANNE</given>
        <family>PETIT</family>
      </name>
      <administrativeGenderCode code="F" codeSystem="2.16.840.1.113883.5.1"/>
      <birthTime value="19480105"/>
    </patient>
    <providerOrganization>
      <id root="2.16.840.1.113883.19.5"/>
      <name>Good Health Clinic</name>
    </providerOrganization>
    <admissionTime value="20120101T22:00"/>
  </patientRole>
</Patients>

我在为以下两项编写XPath表达式时遇到困难:

1955年12月17日出生的患者的姓名和姓氏

2012年1月入住“健康诊所”的患者人数

1 个答案:

答案 0 :(得分:0)

这将为您提供在特定日期出生的患者的name元素:

patientRole/patient[birthTime/@value="19551217"]/name

这将为您提供具有指定组织名称和入场日期的patientRole元素的数量:

count(patientRole[providerOrganization/name="Good Health Clinic"][starts-with(admissionTime/@value,"201201")])