// Remove whitespace appearing as 1st gen children of the document node. // Proper whitespace is automatically added by the XmlTextWriter. private static void RemoveExtraWhitespace(ConfigXmlDocument machineConfig) { ArrayList whitespaceNodes = new ArrayList(); foreach (System.Xml.XmlNode child in machineConfig.ChildNodes) { if (child.NodeType == System.Xml.XmlNodeType.Whitespace) { whitespaceNodes.Add(child); } } foreach (XmlNode whitespace in whitespaceNodes) { machineConfig.RemoveChild(whitespace); } }