我有CDA XML我正在尝试使用 LINQ 解析和查询它。但是,我无法检索这些值。
我正在尝试以下 LINQ 代码:
var cdafile = XDocument.Load("cda.xml");
var patientCity = from c in cdafile.Elements("recordTarget")
.Elements("patientRole")
.Elements("addr")
select (string)c.Element("city").Value;
我在patientCity
. 难道我做错了什么?
<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:sdtc="urn:hl7-org:sdtc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd">
<realmCode code="US"/>
<title>Cypress C32 Patient Test Record: Nelson Tuff</title>
<recordTarget>
<patientRole>
<id root="Cypress" extension="4fe1ecbca9ffcc03cd0004e3"/>
<addr use="HP">
<streetAddressLine>202 Burlington Rd.</streetAddressLine>
<city>Bedford</city>
<state>MA</state>
<postalCode>01730</postalCode>
</addr>
<telecom value="tel:+1-781-271-3000"/>
<patient>
<name>
<given>George</given>
<family>Mathew</family>
</name>
</patient>
</patientRole>
</recordTarget>
</ClinicalDocument>