Sort an Existing XML File
-
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.
-
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.
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