Guest Eregnon Posted September 12, 2002 Posted September 12, 2002 Is there any way of sorting an xml file in vb.net? The two methods described in the documentation - select and dataview.sort - don't seem to physically reorder the records. Quote
*Gurus* Derek Stone Posted September 12, 2002 *Gurus* Posted September 12, 2002 Order is, in most cases, rather irrelevant when it comes to XML, so I doubt the framework includes built-in methods for rearranging the entries in the XML file. Quote Posting Guidelines
Guest Eregnon Posted September 13, 2002 Posted September 13, 2002 How about rearranging the order of any file, or doing any sorting at all? I've got an xml file I read into a dataset that is bound to controls on a form - using the binding context. No matter how I set the select or default view sort criteria, it always displays in the order of the file. Quote
Guest Eregnon Posted September 18, 2002 Posted September 18, 2002 Never mind, I figured out how to do it. Here's a quick sample in case anyone's interested: Dim dsTemp As New DataSet Dim dRows() As DataRow Dim dsReal as new DataSet dsTemp.ReadXml("xmlfilename.xml", XmlReadMode.Auto) dRows = dsTemp.Tables("tablename").Select("", "DisplayOrder") For k = 0 To dRows.Length - 1 dsReal.Tables("tablename").ImportRow(dRows(k)) Next You have to use importrow, since using the rows.add method generates an error. Kind of clumsy, but if you need the physical order of a file changed, I think this is the only way to do it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.