Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
Posted
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.
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...