TigerFan987
MIS
I have an xml file I'm trying to read that looks like this:
And I'm trying to read and output all the streetAddressLine. My code is
It will not output the addressStreetLine. If I remove the xmlns="urn:hl7-org:v3" namespace it works fine. What do I need to do to get it to work with the namespace.
Thanks,
Code:
<?xml version="1.0" encoding="utf-8"?>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:cda="urn:hl7-org:v3" xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xsi:schemaLocation="urn:hl7-org:v3 [URL unfurl="true"]http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd"[/URL] xmlns:sdtc="urn:hl7-org:sdtc">
<recordTarget>
<patientRole>
<addr>
<streetAddressLine>123 MAIN ST</streetAddressLine>
</addr>
<addr>
<streetAddressLine>987 NORTH ST</streetAddressLine>
</addr>
</patientRole>
</recordTarget>
</ClinicalDocument>
And I'm trying to read and output all the streetAddressLine. My code is
Code:
Dim xmlDoc As New XmlDocument()
Dim namespaces As New XmlNamespaceManager(xmlDoc.NameTable)
namespaces.AddNamespace("ns", "urn:hl7-org:v3")
xmlDoc.Load("C:\testXML.xml")
Dim nodes As XmlNodeList = xmlDoc.DocumentElement.SelectNodes("/ClinicalDocument/recordTarget/patientRole/addr", namespaces)
Dim addr As String = ""
For Each node As XmlNode In nodes
addr = node.SelectSingleNode("streetAddressLine").InnerText
MessageBox.Show(addr)
Next
It will not output the addressStreetLine. If I remove the xmlns="urn:hl7-org:v3" namespace it works fine. What do I need to do to get it to work with the namespace.
Thanks,