1.     c#xml

    // 创建一个XmlDocument类的对象
 XmlDocument doc = new XmlDocument();

 

 //将你要写进xml文档中的内容以字符串的形式加载进来
 doc.LoadXml("<Student type='regular' Section='B'><Name>xlh</Name></Student>");

           

 // 保存到你想要保存的文件中
 doc.Save("e:\\student.xml");

 

    2.     c#xml

    // 创建一个XmlDocument类的对象
 XmlDocument doc = new XmlDocument();

 

    // 把你想要读取的xml文档加载进来
 doc.Load("e:/student.xml");

 

    // 读取你指定的节点
 XmlNodeList lis = doc.GetElementsByTagName("Name");

           

    // 取节点中的值
 String str = lis[0].InnerText;

           

    // 显示节点中的值
 MessageBox.Show(str);

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-02-19
猜你喜欢
  • 2021-09-12
  • 2021-09-01
  • 2022-12-23
相关资源
相似解决方案