XML操作大全需要添加的命名空间:
XML操作大全
using System.Xml;
XML操作大全
XML操作大全定义几个公共对象:
XML操作大全XmlDocument xmldoc ;
XML操作大全XmlNode xmlnode ;
XML操作大全XmlElement xmlelem ;
XML操作大全
XML操作大全
1,创建到服务器同名目录下的xml文件:
XML操作大全
XML操作大全
XML操作大全方法一:
XML操作大全xmldoc 
= new XmlDocument ( ) ;
XML操作大全
//加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
XML操作大全
XmlDeclaration xmldecl;
XML操作大全 xmldecl 
= xmldoc.CreateXmlDeclaration("1.0","gb2312",null);
XML操作大全 xmldoc.AppendChild ( xmldecl);
XML操作大全
XML操作大全
//加入一个根元素
XML操作大全
xmlelem = xmldoc.CreateElement ( "" , "Employees" , "" ) ;
XML操作大全xmldoc.AppendChild ( xmlelem ) ;
XML操作大全
//加入另外一个元素
XML操作大全
for(int i=1;i<3;i++)

相关文章:

  • 2022-01-09
  • 2021-07-06
  • 2022-01-23
  • 2021-10-14
  • 2022-01-31
  • 2021-06-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-03
  • 2021-12-09
  • 2021-11-13
  • 2022-02-08
相关资源
相似解决方案