前端之家收集整理的这篇文章主要介绍了
操作XML--C#,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Data;
namespace operate_xml
{
class operate_xml1
{
public XmlDocument myXmlDocument;
/// <summary>
/// 带参构造函数
/// </summary>
/// <param name="xml_name">Xml的路径</param>
public operate_xml1(string xml_name)
{
myXmlDocument = new XmlDocument();
myXmlDocument.Load(xml_name);
}
/// <summary>
/// 更新节点
/// </summary>
/// <param name="xml_name"></param>
/// <param name="name"></param>
/// <param name="value"></param>
/// <param name="weapon"></param>
/// <returns></returns>
public bool updata_xml(string xml_name,string name,string value,string weapon)
{
bool isSuccess = false;
XmlNode node;
node = myXmlDocument.DocumentElement; //获取XML文档的根
try
{
foreach (XmlNode node1 in node.ChildNodes)