I have an XML file :
<School>
<SchoolID>9</SchoolID>
<SchoolID>3</SchoolID>
<SchoolID>3</SchoolID>
<SchoolID>3</SchoolID>
<SchoolID>4</SchoolID>
<SchoolID>1</SchoolID>
<SchoolID>3</SchoolID>
<SchoolID>9</SchoolID>
<SchoolID>2</SchoolID>
</School>
The expecting results should be like:
<School>
<SchoolID>1</SchoolID>
<SchoolID>2</SchoolID>
<SchoolID>3</SchoolID>
<SchoolID>4</SchoolID>
<SchoolID>9</SchoolID>
</School>
My C# code:
var xdoc = XElement.Load(filePath + "input.xml");
var temp = xdoc.Descendants("SchoolID").OrderBy(x => x.Value).Distinct();
xdoc.Save(filePath + "output_final.xml");
However, the result does not change anything.
My temp value is what I want, how can I update my output xml result?
Many thanks.
DY