Is there any way to execute XQuery FLWOR queries from a VB.Net app? Basically I have a huge XML file that I need to validate. It consists basically of phone records (and no I am not working on some secret government project to see if you’re calling your mom often enough). The XML is basically:
And what I want to return would be “Select ServiceNumber, Sum(callminutes), Sum(callcharges) From xmldocument Group By ServiceNumber” The result set would ‘hopefully’ look like this:
Very very simplified what I have tried so far is:
But I get an XML exception about a bad token. The Query that I am trying to pass is simpler that what I want. I figured if I could return SOMETHING I could then work from there. I don’t even know if this is possible. I will keep scouring the web for possible solutions.
Thanks
Journeyman -- The Order of the Seekers of Truth and Penitence
Code:
<usage_details>
<service_details servicenumber="1235551000">
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<service_subtotal qty="4" minutes="2" charges="0.1"/>
</service_details>
<service_details servicenumber="1235552000">
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<usgitem callnumber="123456789" calldate="1/1/2006 9:00:00 AM" callstate="XX" callminutes="0.5" callcharges="0.025" location="Springfield"/>
<service_subtotal qty="3" minutes="1.5" charges="0.75"/>
</service_details>
<usage_total qty="7" minutes="3.5" charges=".175"/>
</usage_details>
And what I want to return would be “Select ServiceNumber, Sum(callminutes), Sum(callcharges) From xmldocument Group By ServiceNumber” The result set would ‘hopefully’ look like this:
Code:
<ServiceNumber>1235551000
<Sumcallminutes>4</Sumcallminutes>
<sumcallcharges>.01</sumcallcharges>
</ServiceNumber>
<ServiceNumber>1235552000
<Sumcallminutes>3</Sumcallminutes>
<sumcallcharges>.075</sumcallcharges>
</ServiceNumber>
Very very simplified what I have tried so far is:
Code:
Passed into below Function
FileName = objFile
xmldoc = Nothing
xmldoc = New System.Xml.XmlDocument()
xmldoc.Load(FileName)
xmlnav = xmldoc.CreateNavigator()
______________________________________________________________________
Private Function UsageDetail(ByVal xmlDoc As System.Xml.XmlDocument, ByVal xmlnav As System.Xml.XPath.XPathNavigator, ByVal Path As String, ByVal CustID As String) As Boolean
xmlnav.Evaluate("for $x in doc(" & Path & ")//usage_details/usage_type/service_details return count($x//usage_details/usage_type/service_details/usageitem)")
x = xmlnav.InnerXml
End Function
But I get an XML exception about a bad token. The Query that I am trying to pass is simpler that what I want. I figured if I could return SOMETHING I could then work from there. I don’t even know if this is possible. I will keep scouring the web for possible solutions.
Thanks
Journeyman -- The Order of the Seekers of Truth and Penitence