-
June 8th, 2011, 02:19 PM
#1
Sorting some XML in C#
I'm trying to sort some XML in C# that looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<websites>
<site language="Spanish" name="Excélsior" order="2">http://www.excelsior.com.mx/</site>
<site language="Japanese" name="TOKYO Web" order="3">http://www.tokyo-np.co.jp/</site>
<site language="Italian" name="Corriere della Sera" order="1">http://www.corriere.it/</site>
<site language="Spanish" name="SpanishTest1" order="4">www.spanishtest1.com</site>
</websites>
I'm trying to implement a feature that will allow a user to sort the websites by their language. The order of the websites should reflect the language, and the language should be sorted alphabetically. I'm completely stuck on how to do this.
So in theory it should probably look like this after a sort:
<?xml version="1.0" encoding="UTF-8"?>
<websites>
<site language="Italian" name="Corriere della Sera" order="1">http://www.corriere.it/</site>
<site language="Japanese" name="TOKYO Web" order="2">http://www.tokyo-np.co.jp/</site>
<site language="Spanish" name="Excélsior" order="3">http://www.excelsior.com.mx/</site>
<site language="Spanish" name="SpanishTest1" order="4">www.spanishtest1.com</site>
</websites>
-
June 9th, 2011, 02:12 AM
#2
Re: Sorting some XML in C#
Just guess, but LINQ to XML wouldn't help? Because it seems to me that you don't want to sort the XML, but the XML Document buit in the memory.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|