[C#] 纯文本查看 复制代码 private void button1_Click(object sender, RoutedEventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode node = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null);
xmlDoc.AppendChild(node);
string nameSpaceURI = "http://www.w3.org/1999/XMLSchema";
XmlElement Envelope = xmlDoc.CreateElement("tns", "Envelope", nameSpaceURI);
//Envelope.SetAttribute("xmlns:SOAP-ENV", nameSpaceURI);
//Envelope.SetAttribute("xmlns:xsd", "http://www.w3.org/1999/XMLSchema");
//Envelope.SetAttribute("xmlns:xsi", "http://www.w3.org/1999/XMLSchema-instance");
Envelope.InnerText = null;
XmlNode root = xmlDoc.DocumentElement??(XmlNode)xmlDoc;
root.AppendChild(Envelope);
XmlElement Header = xmlDoc.CreateElement("tns", "Header", nameSpaceURI);//创建一个<Node>节点
//Header.InnerText = null;
Envelope.AppendChild(Header);
xmlDoc.Save(@"c:\test.xml");
}
|