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:
Pradeep ChandrakerPosted Jun 9, 2011, 9:44 PM
string strNewXML = newDoc.ToString();
This is what your code should be:
Adam TurnerPosted Jun 10, 2011, 11:34 AM
Adam TurnerPosted Jun 9, 2011, 9:01 PM
Here is what I have so far:
PopulateBoxes(); //you shouldn't have to worry about this, it just updates based on the order, but I'll post it below
/***************************************************/
Pradeep ChandrakerPosted Jun 9, 2011, 1:10 AM
Mahesh ChandPosted Jun 8, 2011, 10:49 PM
Pradeep ChandrakerPosted Jun 8, 2011, 8:36 PM
string strXML = ""
+ "
+ "
+ "
+ "
+ "
+ "
XDocument oXDoc = XDocument.Parse(strXML);
var newDoc = new XDocument(new XElement("websites",
from p in oXDoc.Element("websites").Elements("site")
orderby p.Attribute("language").Value
select p));
string strNewXML = newDoc.ToString();
The strNewXML string variable will have the sorted xml string.
Mahesh ChandPosted Jun 8, 2011, 6:23 PM
VulpesPosted Jun 8, 2011, 4:22 PM
Otherwise it's not so easy and you'd need to know in advance what variations might arise to be able to come up with a sensible approach.