Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Sort an Existing XML File

Sort an Existing XML File

Scheduled Pinned Locked Moved C#
xmldatabasehelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ASPnoob
    wrote on last edited by
    #1

    Hello All, I've written a Windows application for adding data into an existing XML file that has the following schema:

    There are more than one < lecture > node in the file, the above code just shows the schema of the file. The user adds data to an existing XML file by entering values into textboxes which correspond to the various child nodes of the < lecture > nodes in the XML file. Then when the user is done he/she can simply click the submit button to add data to the existing XML file. As it is, the app works but the data are not sorted. I would like to sort the XML file by date so that the dates are in ascending order. Please point me to a web page that discusses how this can be done or show me an example. Thanks in advance for your help.

    L 1 Reply Last reply
    0
    • A ASPnoob

      Hello All, I've written a Windows application for adding data into an existing XML file that has the following schema:

      There are more than one < lecture > node in the file, the above code just shows the schema of the file. The user adds data to an existing XML file by entering values into textboxes which correspond to the various child nodes of the < lecture > nodes in the XML file. Then when the user is done he/she can simply click the submit button to add data to the existing XML file. As it is, the app works but the data are not sorted. I would like to sort the XML file by date so that the dates are in ascending order. Please point me to a web page that discusses how this can be done or show me an example. Thanks in advance for your help.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      ASPnoob wrote:

      Please point me to a web page

      Google is very good at doing that. A fairly simple solution would be to deserialize the XML data into a collection class[^], then sort it before rewriting it back to the XML file.

      Veni, vidi, abiit domum

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups