HUX布斯
XmlDocument doc = new XmlDocument();doc.Load("c:\\config.xml");XmlNodeList list = doc.SelectNodes("/configuration/item");List<XmlNode> arrNode = new List<XmlNode>();foreach (XmlNode node in list){arrNode.Add(node);}// 关键:使用匿名方法,按节点的Value排序arrNode.Sort(delegate(XmlNode x, XmlNode y){return x.Value.CompareTo(y.Value);//如果要降序排序,改成下面这句//return -x.Value.CompareTo(y.Value);});doc = new XmlDocument();System.Xml.XmlDeclaration xdec = doc.CreateXmlDeclaration("1.0 ", "GB2312 ", null);doc.AppendChild(xdec);foreach(XmlNode xn in arrNode)doc.AppendChild(xn);doc.Save("c:\\config.xml");