c#中带头(声明)的xml(封装)生成代码。
代码如下:
XmlDocumen来源gao($daima.com搞@代@#码网t downLoadFilexml = new XmlDocument();
XmlElement root = null;
XmlElement kisokChild = null;
//生成xml的头
XmlNode xmlnode= downLoadFilexml.CreateXmlDeclaration(“1.0”, “utf-8”, null);
downLoadFilexml.AppendChild(xmlnode);
root = downLoadFilexml.CreateElement(“test”);
root.SetAttribute(“Guid”,“1”);
root.SetAttribute(“BuildID”,”0″);
downLoadFilexml.AppendChild(root);
kisokChild = downLoadFilexml.CreateElement(“testChild”);
kisokChild.SetAttribute(“Interval”,”111″);
root.AppendChild(kisokChild);
Response.Write(downLoadFilexml.OuterXml);
Response.End();
XmlElement root = null;
XmlElement kisokChild = null;
//生成xml的头
XmlNode xmlnode= downLoadFilexml.CreateXmlDeclaration(“1.0”, “utf-8”, null);
downLoadFilexml.AppendChild(xmlnode);
root = downLoadFilexml.CreateElement(“test”);
root.SetAttribute(“Guid”,“1”);
root.SetAttribute(“BuildID”,”0″);
downLoadFilexml.AppendChild(root);
kisokChild = downLoadFilexml.CreateElement(“testChild”);
kisokChild.SetAttribute(“Interval”,”111″);
root.AppendChild(kisokChild);
Response.Write(downLoadFilexml.OuterXml);
Response.End();
以上就是c#中带头(声明)的xml(封装)生成的详细内容,更多请关注gaodaima搞代码网其它相关文章!