发布于2026-07-22 阅读(0)
扫一扫,手机访问
protected void Button1_Click(object sender, EventArgs e)//创建xml
{
//声明
XmlDocument x = new XmlDocument();
//创建
XmlDeclaration xd = x.CreateXmlDeclaration("1.0", "GB2312", null);
x.AppendChild(xd);
//创建根节点
XmlElement element = x.CreateElement("Books");
x.AppendChild(element);
//添加Books的子节点
XmlNode book = x.CreateElement("Book");
//给Book添加元素
XmlElement bookname = x.CreateElement("书名");
bookname.InnerText = "三国";
//逐级添加到节点上
book.AppendChild(bookname);
element.AppendChild(book);
x.AppendChild(element);
//保存文档(如果已经存在该文件,则更新之;如果没有,则创建该文件)
x.Sa ve(@"F:/Books.xml");
} 下一篇:XML和YAML的使用方法
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
售后无忧
立即购买>office旗舰店
正版软件
正版软件
正版软件
正版软件
正版软件
1
2
3
7
8