Hi Folks! I sure hope someone can guide me on this issue.
Here is the XML document I'm working from (nda.xml):
[code=xml]
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelop e xmlns:soap="htt p://www.w3.org/2003/05/soap-envelope" xmlns:loc="http ://localhost:2680/">
<soap:Header/>
<soap:Body>
<loc:CreateND A>
<loc:docname>re m12345</loc:docname>
<loc:encodeddat a>aaabbbcccddde eefff</loc:encodeddata >
<!--Zero or more repetitions:-->
<loc:parmeters> value1</loc:parmeters>
<loc:parmeters> value2</loc:parmeters>
<loc:parmeters> value3</loc:parmeters>
</loc:CreateNDA>
</soap:Body>
</soap:Envelope>
I'm writing this process in VB.NET. Here is my code:
Dim fs As New FileStream("C:\ NDA\logs\rem999 9.log", FileMode.Create New, FileAccess.Writ e)
Dim w As New StreamWriter(fs )
Dim doc = New XPathDocument(" C:\NDA\nda.xml" )
Dim nav = doc.CreateNavig ator()
Dim xmlManager = New XmlNamespaceMan ager(nav.NameTa ble)
xmlManager.AddN amespace("loc", "http://localhost:2680/")
xmlManager.AddN amespace("soap" , "http://www.w3.org/2003/05/soap-envelope")
Dim xpathExpress = nav.Compile("//soap:Envelope/soap:Body/loc:CreateNDA/loc:docname")
xpathExpress.Se tContext(xmlMan ager)
Dim xIterator = nav.Select(xpat hExpress)
w.WriteLine(xIt erator.Current. Value)
[/code]
When this code excutes, I get the following results:
"rem12345aaabbb cccdddeeefffval ue1value2value3 "
With an xpathExpress variable set to "//soap:Envelope/soap:Body/loc:CreateNDA/loc:docname" I would expect my results to be equal to "rem12345" only.
When I change the xpathExpress to point to "//soap:Envelope/soap:Body/loc:CreateNDA/loc:encodeddata " the results are the same "rem12345aaabbb cccdddeeefffval ue1value2value3 ". In this case, I would expect my results to be equal to "aaabbbcccdddee efff".
I assume there is something wrong with my code, but I'm new to XML and Xpath. Anyone have any thoughts on why I'm getting the results I am?
Any help is greatly apprciated!!
Thanks!
Leafy
Here is the XML document I'm working from (nda.xml):
[code=xml]
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelop e xmlns:soap="htt p://www.w3.org/2003/05/soap-envelope" xmlns:loc="http ://localhost:2680/">
<soap:Header/>
<soap:Body>
<loc:CreateND A>
<loc:docname>re m12345</loc:docname>
<loc:encodeddat a>aaabbbcccddde eefff</loc:encodeddata >
<!--Zero or more repetitions:-->
<loc:parmeters> value1</loc:parmeters>
<loc:parmeters> value2</loc:parmeters>
<loc:parmeters> value3</loc:parmeters>
</loc:CreateNDA>
</soap:Body>
</soap:Envelope>
I'm writing this process in VB.NET. Here is my code:
Dim fs As New FileStream("C:\ NDA\logs\rem999 9.log", FileMode.Create New, FileAccess.Writ e)
Dim w As New StreamWriter(fs )
Dim doc = New XPathDocument(" C:\NDA\nda.xml" )
Dim nav = doc.CreateNavig ator()
Dim xmlManager = New XmlNamespaceMan ager(nav.NameTa ble)
xmlManager.AddN amespace("loc", "http://localhost:2680/")
xmlManager.AddN amespace("soap" , "http://www.w3.org/2003/05/soap-envelope")
Dim xpathExpress = nav.Compile("//soap:Envelope/soap:Body/loc:CreateNDA/loc:docname")
xpathExpress.Se tContext(xmlMan ager)
Dim xIterator = nav.Select(xpat hExpress)
w.WriteLine(xIt erator.Current. Value)
[/code]
When this code excutes, I get the following results:
"rem12345aaabbb cccdddeeefffval ue1value2value3 "
With an xpathExpress variable set to "//soap:Envelope/soap:Body/loc:CreateNDA/loc:docname" I would expect my results to be equal to "rem12345" only.
When I change the xpathExpress to point to "//soap:Envelope/soap:Body/loc:CreateNDA/loc:encodeddata " the results are the same "rem12345aaabbb cccdddeeefffval ue1value2value3 ". In this case, I would expect my results to be equal to "aaabbbcccdddee efff".
I assume there is something wrong with my code, but I'm new to XML and Xpath. Anyone have any thoughts on why I'm getting the results I am?
Any help is greatly apprciated!!
Thanks!
Leafy
Comment