在内存里建立Xml对象
XmlDocument xml = new XmlDocument(); //建立XmlDomcument对象
XmlDeclaration Declaration = xml.CreateXmlDeclaration("1.0", "utf-8", null); //Xml Declaration(Xml声明)
XmlNode RootNode = xml.CreateNode(XmlNodeType.Element,"v","Games","www-microsoft-game");
xml.AppendChild(RootNode);
XmlNode node1 = xml.CreateNode(XmlNodeType.Element, "v", "Game", "www-microsoft-game");
RootNode.AppendChild(node1);
node1.Attributes.Append(xml.CreateAttribute("name")).InnerText = "文明3";
node1.AppendChild(xml.CreateNode(XmlNodeType.Element,"Price",null)).InnerText = "100";
XmlNode node2 = xml.CreateNode(XmlNodeType.Element, "v", "Game", "www-microsoft-game");
RootNode.AppendChild(node2);
node2.Attributes.Append(xml.CreateAttribute("name")).InnerText = "帝国时代";
node2.AppendChild(xml.CreateNode(XmlNodeType.Element, "Price", null)).InnerText = "300";
xml.InsertBefore(Declaration, xml.DocumentElement);
请注意,如果Xml文档里没有明确指出当前节点的命名空间,那么当前节点的命名空间继承其父节点的命名空间
假