rwallacej
asked on
Insert XElement in right place in XDocument
I have inherited following code. It keeps list of ManualInputs in an XML file a bit like this. Code to add new items is as follows. The problem with this is it always adds the new element to end of document. Instead I'd like to keep it in order of timestamp. You can see here that 2011-01-10 was added and put at end, instead I want it to be added and keep order of timestamps ascending.
Thanks in advance for help
Dim manualInputsDoc as XDocument = GetTheXDocument
manualInputsDoc.Root.Add(e lement)
<?xml version="1.0" encoding="utf-8"?>
<ManualInputs>
<ManualInput Timestamp="2011-01-01">
<Field1>100</Field1>
</ManualInput>
<ManualInput Timestamp="2011-03-01">
<Field1>200</Field1>
</ManualInput>
<ManualInput Timestamp="2011-05-01">
<Field1>123</Field1>
</ManualInput>
<ManualInput Timestamp="2011-01-10">
<Field1>444</Field1>
</ManualInput>
</ManualInputs>
Thanks in advance for help
Dim manualInputsDoc as XDocument = GetTheXDocument
manualInputsDoc.Root.Add(e
<?xml version="1.0" encoding="utf-8"?>
<ManualInputs>
<ManualInput Timestamp="2011-01-01">
<Field1>100</Field1>
</ManualInput>
<ManualInput Timestamp="2011-03-01">
<Field1>200</Field1>
</ManualInput>
<ManualInput Timestamp="2011-05-01">
<Field1>123</Field1>
</ManualInput>
<ManualInput Timestamp="2011-01-10">
<Field1>444</Field1>
</ManualInput>
</ManualInputs>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER