This article describes the method of simply writing to xml files in C#. Share it for your reference. The specific implementation method is as follows:
static void writeTree(XmlNode xmlElement, int level) { String levelDepth = ""; for(int i=0;i<level;i++) { levelDepth += " "; } ("\n{0}<{1}",levelDepth,); XmlAttributeCollection xmlAttributeCollection = ; foreach(XmlAttribute x in xmlAttributeCollection) { (" {0}='{1}'",,); } (">"); XmlNodeList xmlNodeList = ; ++level; foreach(XmlNode x in xmlNodeList) { if( == ) { writeTree((XmlNode)x, level); } else if( == ) { ("\n{0} {1}",levelDepth,().Trim()); } } ("\n{0}</{1}>",levelDepth,); }
I hope this article will be helpful to everyone's C# programming.