我已经通过以下代码编写了xml
if (!File.Exists("d:\\s.xml"))
{
XmlTextWriter textWriter = new XmlTextWriter("d:\\s.xml", null);
textWriter.WriteStartDocument();
textWriter.WriteStartElement("node");
textWriter.WriteStartElement("zone");
textWriter.WriteStartElement("dt");
textWriter.WriteStartElement("Mn");
textWriter.WriteString("m1");
textWriter.WriteEndElement();
textWriter.WriteStartElement("Dist");
textWriter.WriteString("Colony");
textWriter.WriteEndElement();
textWriter.WriteEndElement();
textWriter.WriteEndDocument();
textWriter.Close();
}
输出为
<?xml version="1.0"?>
<Node>
<Zone>
<Dt>
<mn>m1</mn>
<Dist>Colony</Dist>
</Dt>
</Zone>
</Node>
现在我需要将以下 xml 附加到已经存在的 xml 文件中
<Dt1>
<mn>m1</mn>
<Dist>Colony</Dist>
</Dt1>