XmlNode root = xmlDoc.CreateNode(XmlNodeType.Element, "XML", "");
xmlDoc.AppendChild(root); //添加参数设置节点
XmlNode parConfig = xmlDoc.CreateNode(XmlNodeType.Element, "参数", "");
root.AppendChild(parConfig); //属性一
XmlElement str1 = xmlDoc.CreateElement("PROPONE");
str1 .InnerText = "";
parConfig.AppendChild(str1 );
//属性二
XmlElement str2 = xmlDoc.CreateElement("PROPONETWO");
str2.InnerXml = "ddfafdfsdfsdf";
parConfig.AppendChild(str2);
//属性三
XmlElement str3= xmlDoc.CreateElement("PROPONETHREE");
str3.InnerXml = "";
parConfig.AppendChild(str3);
这个生成后在每个节点会自动添加一个xmlns="" 的东西,网上查说是命名空间,我想把这个去掉,因为它会在每一层都添加,怎么去了呀,初学导出XML,还请高手们多多指教
xmlDoc.AppendChild(root); //添加参数设置节点
XmlNode parConfig = xmlDoc.CreateNode(XmlNodeType.Element, "参数", "");
root.AppendChild(parConfig); //属性一
XmlElement str1 = xmlDoc.CreateElement("PROPONE");
str1 .InnerText = "";
parConfig.AppendChild(str1 );
//属性二
XmlElement str2 = xmlDoc.CreateElement("PROPONETWO");
str2.InnerXml = "ddfafdfsdfsdf";
parConfig.AppendChild(str2);
//属性三
XmlElement str3= xmlDoc.CreateElement("PROPONETHREE");
str3.InnerXml = "";
parConfig.AppendChild(str3);
这个生成后在每个节点会自动添加一个xmlns="" 的东西,网上查说是命名空间,我想把这个去掉,因为它会在每一层都添加,怎么去了呀,初学导出XML,还请高手们多多指教
http://student.csdn.net/space.php?uid=259947&do=blog&id=47405
<XML>
<参数>
<PROPONE>
</PROPONE>
<PROPONETWO>ddfafdfsdfsdf</PROPONETWO>
<PROPONETHREE />
</参数>
</XML>
XmlDocument xmlDoc = new XmlDocument();
//创建XML文件描述
XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "GB2312", null);
xmlDoc.AppendChild(dec);