private void SortAttributesAttributes(XmlElement el)
{
ArrayList al = new ArrayList();
foreach (XmlAttribute a in el.Attributes)
al.Add(a.Name);
al.Sort();
string[] names = (string[])al.ToArray(typeof(string));
al.Clear();
foreach (string name in names)
al.Add(el.RemoveAttributeNode(
el.GetAttributeNode(name)));
foreach (XmlAttribute a in al)
// Exclude xmlns="" here.
if (a.Name != "xmlns")// || a.Value != String.Empty)
el.SetAttributeNode(a);
}