473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML SelectSingleNode issue

2
I am using VB .Net 2003 XML namespace to get specified values from an XML document. I have used Stylus Studio 2007 to verify that my XPath query is valid and returns the node/nodes I am looking for. However in VB .Net the below code does not return any nodes. By the end of the day I want to select a single node and get the value and insert than value into a database.

THANKS!
Rick63

//////////////////////// VB Code ////////////////////////////////////////////////
Dim xmlDoc As XmlDocument
Dim xmlNameNode As XmlNode
Dim xmlAgeNode As XmlNode
Dim FileName As String = "c:\sampleXML.xml"

xmlDoc = New XmlDocument
xmlDoc.Load(FileName)
xmlNameNode = xmlDoc.SelectSingleNode("//ClinicalDocument/recordTarget/patientRole/patient/name")

If Not xmlNameNode Is Nothing Then
Messagebox.show("WHoooooo Hoooo")
'NEVER jumps into here!
End If
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////// THE XML Document /////////////////////////////////////////////////////
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="CDA.xsl"?>
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 file:///c:/CDA.xsd">
<!--
************************************************** ******
CDA Header
************************************************** ******
-->
<!-- TODO: Need to get report title definition-->
<title>This is a sample title</title>
<!-- TODO: effective time is the time of the submission by the patient-->
<effectiveTime value="20070318"/>
<languageCode code="en-US"/>
<recordTarget>
<patientRole>
<patient>
<name>
<!-- TODO: Patient last/first below-->

<family>First Name</family>
</name>
<administrativeGenderCode code="M" codeSystem="2.16.840.1.113883.5.1"/>
<birthTime value="19740322"/>
</patient>
</patientRole>
</recordTarget>
<author>
<time value="2000040714"/>
<assignedAuthor>
<assignedPerson>
<name>
<!-- TODO: Patient last/first below-->
<given>Last Name</given>
<family>First Name</family>
</name>
</assignedPerson>
</assignedAuthor>
</author>
<component>
<structuredBody>
<!--
************************************************** ******
History of Present Illness section
************************************************** ******
-->
<component>
<section>
<code code="10164-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Chief Complaint</title>
<text>
<content>
<!-- TODO: Add Chief Complaint Text Here-->
This is a sample chief complaint.
</content>
</text>
</section>
</component>
<!--
************************************************** ******
Medical Allergies
************************************************** ******
-->
<component>
<section>
<code code="10155-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Medical Allergies</title>
<text>
<list>
<!-- TODO: Add each allergy as a list item here-->
<item>Penicillin - Hives</item>
<item>Aspirin - Wheezing</item>
<item>Codeine - Itching and nausea</item>
</list>
</text>
</section>
</component>

<!--
************************************************** ******
Medications section
************************************************** ******
-->
<component>
<section>
<code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Medications</title>
<text>
<list>
<!-- TODO: Add each medication as a list item here-->
<item>Theodur 200mg BID</item>
<item>Proventil inhaler 2puffs QID PRN</item>
</list>
</text>
</section>
</component>

<!--
************************************************** ******
Family History section
************************************************** ******
-->
<component>
<section>
<code code="10157-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Family history</title>
<text>
<list>
<!-- TODO: Add each family history row as a list item here-->
<item>Father - still living - thyroid cancer.</item>
<item>Mother - died at 67 - car accident.</item>
</list>
</text>
</section>
</component>
<!--
************************************************** ******
Problem and Surgical History section
************************************************** ******
-->
<component>
<section>
<code code="10153-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title> Problem and Surgical History</title>
<text>
<list>
<!-- TODO: add items from problem and surgery history here-->
<item>Asthma</item>
<item>High blood pressure : father</item>
<item>Heart attack</item>
</list>
</text>
</section>
</component>
<!--
************************************************** ******
Hospitalization History section
************************************************** ******
-->
<component>
<section>
<code code="11336-5" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Hospitalization History</title>
<text>
<list>
<!-- TODO: Add each hospitalization history row as a list item here-->
<item>St. Paul - Chest Pain - 2004</item>
<item>St. Paul - Broken Arm - 1999</item>
</list>
</text>
</section>
</component>
<!--
************************************************** ******
Social History section
************************************************** ******
-->
<component>
<section>
<code code="29762-2" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC"/>
<title>Social History</title>
<text>
<list>
<!-- TODO: add social history items here-->
<item>Smoking :: 1 PPD, 5 years. Quit 2 years ago.</item>
<item>Alcohol :: No</item>
</list>
</text>
</section>
</component>
</structuredBody>
</component>
</ClinicalDocument>
Apr 1 '07 #1
2 3029
iburyak
1,017 Expert 512MB
Try to remove stylesheet information from your XML.


[PHP]<?xml-stylesheet type="text/xsl" href="CDA.xsl"?>[/PHP]


Hope it helps.

Did you know that you can pass valid XML to SQL stored procedure for processing?

Good Luck.
Apr 1 '07 #2
Rick63
2
Thanks iburyak, I actually realized that my XPath was not looking in the name space as declared in the XML header (xmlns="urn:hl7-org:v3"). Below is a code snippet that worked

////////////////////////////////////////VB Code //////////////////////////////////////////////////////////

'map namespaces to prefixes for querying purposes
nsmanager.AddNamespace("ns", "urn:hl7-org:v3")

xNode = xDoc.SelectSingleNode("/ns:ClinicalDocument/ns:recordTarget/ns:patientRole/ns:patient/ns:name/ns:family", nsmanager)
If Not xNode Is Nothing Then
messagebox.show xNode.InnerText
Else

End If

Thanks for the help.
Rick63
Apr 1 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Glenn Venzke | last post by:
I'm trying to invoke the "selectsinglenode" method on an XmlDocument object, but it doesn't seem able to find the node I want. I'm able to access the document root but when I try to parse an...
5
by: Colin Young | last post by:
I have the following XML ('Offer' only appears once in the XML): <OfferSheetXML xmlns="http://localhost/GBWPipeline/OfferSheetSchema.xsd"> <Offer> <OfferSheetId>31</OfferSheetId> </Offer>...
7
by: Sashi | last post by:
Two questions: (1) I can pull the text of an XML element as a string just fine using code as such: strSomeString = myXmlDoc.SelectSingleNode("/Element1/Element2/Element3",...
0
by: Savaticus | last post by:
This is VBScript centric I have an issue where in windows 2k the selectSingleNode method returns values as expected but in Windows XP I get an error Object Required:...
19
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
5
by: anupamjain | last post by:
Tired, Exhausted, searched the web, usenets,forums thorughly but still clueless. I guess it's time to post on the group : This is the issue I have been trying to resolve since today morning : ...
0
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. ...
3
by: =?Utf-8?B?bmVlZDJzY3ViYQ==?= | last post by:
I have the following code snipet: .... _xmldocManifest.Load(strManifestAbsolutePath) Dim manifestNSManager As XmlNamespaceManager = New XmlNamespaceManager(_xmldocManifest.NameTable)...
3
by: Ben | last post by:
Hi We have the XML Below <Products> <Item Code="1"> <PN>Name</PN> <PC>ProductCode</PC> <MC>Manufacturer</MC> ......
0
by: Masher5050 | last post by:
Hello, I am having an issue getting values out of this XML document. Sample of XML <?xml version="1.0" encoding="UTF-8"?> <LmbLeads xmlns="http://www.lmb.com/hla/2006"> <LmbLead>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.