user158977
user158977

Reputation: 91

C#-Sorting XML elements -Possible?(without ADO.NET)

Just i need to recreate a xml file after appling sorting on key filed element(say EmpID),The thing is ,i should not use ADO.NET.Which is the best sort to go ahead ?.To do so,What XML Class do i need to use?,LINQ is quite handy?

Upvotes: 1

Views: 342

Answers (2)

Gregoire
Gregoire

Reputation: 24872

No need for c\ to do this. you can do it via an XSL file

<xsl:template match="/">
 <xsl:apply-template select="yourlementnode">
    <xsl:sort select="EmpID" order="ascending" /> 
  </xsl:apply-template> 
</xsl:template>

Upvotes: 4

Jon Skeet
Jon Skeet

Reputation: 1503140

LINQ to XML would probably be your best bet. You could either move the elements "in place" or (possibly more easily) create a new document with the re-ordered elements.

If you can give us some sample XML (input and desired output) it should be fairly easy to come up with some example code.

Upvotes: 0

Related Questions