troubleshooting Question

I would like to filter and then group/sort the following XML by the DOCUMENT_TYPE

Avatar of t_mych
t_mych asked on
Visual Basic.NET
1 Comment1 Solution165 ViewsLast Modified:
I would like to filter and then group/sort the following XML by the DOCUMENT_TYPE:
...
- <QITEM EntryID="AAABDpAAIAACRUjAAJ">
  <F_Busy>False</F_Busy>
  <F_Delay />
  <F_EntryTime>7/1/2005 3:37:33 PM</F_EntryTime>
  <F_GroupID />
  <F_Priority>5</F_Priority>
  <F_TimeOut />
  <F_UserID />
  <QDOC_ID>304766820</QDOC_ID>
  <DOCUMENT_TYPE>MED-REFERRAL</DOCUMENT_TYPE>
  <F_DOCUMENTCLASS />
  </QITEM>
- <QITEM EntryID="AAABDpAAIAACRUjAAK">
  <F_Busy>False</F_Busy>
  <F_Delay />
  <F_EntryTime>7/1/2005 3:59:57 PM</F_EntryTime>
  <F_GroupID />
  <F_Priority>5</F_Priority>
  <F_TimeOut />
  <F_UserID />
  <QDOC_ID>304766821</QDOC_ID>
  <DOCUMENT_TYPE>PREFETCH-SHEET</DOCUMENT_TYPE>
  <F_DOCUMENTCLASS />
  </QITEM>
...

I am reading XML file into strongly typed dataset OTHDISTQ and then sorting it by DefaultView.Sort = "DOCUMENT_TYPE" (see code below). The datagrid that is bound to the dataset displays  s o r t e d  data correctly, however i need help figuring out   h o w   t o   s a v e  sorted data back into XML (both approaches below using WriteXML() are not successful at it).
Thanks in advance!


            Dim dsOTHDIST As New OTHDISTQ
            dsOTHDIST.ReadXml("C:\Temp\OTHDISTQ.xml")

            Dim dv As New DataView
            If Not dsOTHDIST Is Nothing Then
                dv.Table = dsOTHDIST.Tables(1)
            End If            

            With dsOTHDIST.Tables(1)
                .DefaultView.Sort = "DOCUMENT_TYPE"
                .DefaultView.Table.AcceptChanges()
                DataGrid1.DataSource = .DefaultView.Table
                .DefaultView.Table.DataSet.WriteXml("C:\Temp\XMLData\OTHDISTQ.xml")
            End With
           
            Dim dsSorted As New DataTable
            Dim objDataSource As Object = DataGrid1.DataSource
            dsSorted = DirectCast(objDataSource, DataTable)
            dsSorted.DataSet.WriteXml("C:\Temp\XMLData\OTHDISTQ.xml")
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros