Sort an XML document using DataView

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am tring to use DataView Sort ability to sort an XML document, here are my
code snippet:

ds1.ReadXml("c:\temp\catalog1.xml")
ds1.Tables(0).DefaultView.Sort = "ProdName"
ds1.WriteXml("c:\temp\catalog2.xml")

Does not work at all, can someone help?

TIA
 
The Sort property only applies if you look at the table through a
DataView (the DefaultView in this case). Since a DataView doesn't have
a WriteXml method, you'd have to hand craft the code to write the XML
out in specific order (perhaps by looping through the records as
sorted by DefaultView).
 
Back
Top