t_mych
asked on
I would like to filter and then group/sort the following XML by the DOCUMENT_TYPE
I would like to filter and then group/sort the following XML by the DOCUMENT_TYPE:
...
- <QITEM EntryID="AAABDpAAIAACRUjAA J">
<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_I D>
<DOCUMENT_TYPE>MED-REFERRA L</DOCUMEN T_TYPE>
<F_DOCUMENTCLASS />
</QITEM>
- <QITEM EntryID="AAABDpAAIAACRUjAA K">
<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_I D>
<DOCUMENT_TYPE>PREFETCH-SH EET</DOCUM ENT_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.AcceptC hanges()
DataGrid1.DataSource = .DefaultView.Table
.DefaultView.Table.DataSet .WriteXml( "C:\Temp\X MLData\OTH DISTQ.xml" )
End With
Dim dsSorted As New DataTable
Dim objDataSource As Object = DataGrid1.DataSource
dsSorted = DirectCast(objDataSource, DataTable)
dsSorted.DataSet.WriteXml( "C:\Temp\X MLData\OTH DISTQ.xml" )
...
- <QITEM EntryID="AAABDpAAIAACRUjAA
<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_I
<DOCUMENT_TYPE>MED-REFERRA
<F_DOCUMENTCLASS />
</QITEM>
- <QITEM EntryID="AAABDpAAIAACRUjAA
<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_I
<DOCUMENT_TYPE>PREFETCH-SH
<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
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.AcceptC
DataGrid1.DataSource = .DefaultView.Table
.DefaultView.Table.DataSet
End With
Dim dsSorted As New DataTable
Dim objDataSource As Object = DataGrid1.DataSource
dsSorted = DirectCast(objDataSource, DataTable)
dsSorted.DataSet.WriteXml(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.