Click here to Skip to main content
15,067,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what is the xpath of xml to read node PatientDrugDetail
<soap:Envelope xmlns:soap="" xmlns:xsd="" xmlns:xsi="">
<GetPatientFullMedicationHistoryResponse xmlns="">




1 solution

Are you using XmlDocument.SelectNodes ?

If so, I suspect that you are running into a problem with the namespace on the third line -- which applies to all the elements within the GetPatientFullMedicationHistoryResponse element.

In order to use XPath to select the desired Element you need to specify a prefix to use by using an XmlNamespaceManager. (It's counter-intuitive.)[^]

I don't have the code I use to do that handy and I still haven't gotten around to writing an article on it.

If I recall correctly, you'll need to use;
System.Xml.XmlNamespaceManager nsm = new System.Xml.XmlNamespaceManager ( Document.NameTable ) ;
nsm.AddNamespace ( someprefix , "" ) ;

Then use someprefix as the prefix.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900