Hi - I have an XML file which is formatted like so:
I am trying to get to the "totalrows" element and after a bit of digging I found out that because namespaces are involved I can't just use xpath to get there without using namespacemanager. I've read up what I can but I still can't quite get to the little bugger so can anyone please steer me in the right direction. Here's what I have:
Thanks,
Tom
HTML:
<result>
<ResultExDataset xmlns="http://www.mysite/Results.xsd">
<ResultSummary>
<result>OK</result>
<lasterrtype>None</lasterrtype>
<lasterrtypevalue>0</lasterrtypevalue>
<errordesc />
<totalrows>0</totalrows>
<morerowsavailable>False</morerowsavailable>
</ResultSummary>
</ResultExDataset>
<TransactionsDataset xmlns="http://www.mysite/Transactions.xsd" />
</result>
I am trying to get to the "totalrows" element and after a bit of digging I found out that because namespaces are involved I can't just use xpath to get there without using namespacemanager. I've read up what I can but I still can't quite get to the little bugger so can anyone please steer me in the right direction. Here's what I have:
VB.NET:
Dim XMLdoc As New XmlDocument()
XMLdoc.Load("C:\Trans.xml")
Dim nsMgr As Xml.XmlNamespaceManager
nsMgr = New Xml.XmlNamespaceManager(XMLdoc.NameTable)
nsMgr.AddNamespace("RES", "http://www.mysite/Results.xsd")
nsMgr.AddNamespace("TRANS", "http://www.mysite/Transactions.xsd")
MsgBox(XMLdoc.SelectSingleNode("RES:ResultExDataset/RES:ResultSummary/RES:totalrows", nsMgr).InnerText)
Thanks,
Tom
Last edited: