I have a xml document in a string I would like to read the value of the tag, which has more than one reference in the full XML, so I can't read it uniquely with other methods. I tried with this code:
XDocument cdafile = XDocument.Parse(cXml)//The Xml code;
var myElement = cdafile.Elements("recordTarget").Elements("patientRole").Elements("patient").Elements("name").Elements("given");
But the value is always empty. Maybe I should enter the namespace urn: hl7-org: v3, but I don't know how.
Here is the xml code.
<?xml version="1.0" encoding="UTF-8"?>
<ClinicalDocument xsi:schemaLocation="urn:hl7-org:v3 CDA.xsd"
xmlns="urn:hl7-org:v3" xmlns:mif="urn:hl7-org:v3/mif"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<recordTarget>
<patientRole classCode="PAT">
<id root="2.16.840.1.113883.2.9.4.3.2" extension="DC234RT566Y7"
assigningAuthorityName="LONDON" />
<addr use="HP">
<houseNumber>5</houseNumber>
<streetName>MY STREET NAME</streetName>
<city>LONDON</city>
<postalCode>12345</postalCode>
<county>GB</county>
</addr>
<patient>
<name>
<given>NAME</given>
<family>SURNAME</family>
</name>
<administrativeGenderCode codeSystem="2.16.840.1.113883.5.1" code="F" displayName="F" />
<birthTime value="20030215" />
<birthplace>
<place>
<addr>
<county>GB</county>
<city>LONDON</city>
<postalCode />
</addr>
</place>
</birthplace>
</patient>
</patientRole>
</recordTarget>
<author>
<time value="20200429110507" />
<assignedAuthor>
<id root="2.16.840.1.113883.2.9.4.3.2" extension="CF1234567890"
assigningAuthorityName="NYC" />
<id root="2.16.840.1.113883.2.9.2.160.4.2" extension="414681"
assigningAuthorityName="LONDON" />
<assignedPerson>
<name>
<prefix>DR.</prefix>
<given>DRNAME</given>
<family>DRSURNAME</family>
</name>
</assignedPerson>
</assignedAuthor>
</author>
</ClinicalDocument>