Common/XML.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Text;
using System.Xml;
namespace RM.Common
{
/*XML操作类*/
/// <summary>
/// 必需用XPATH表达式来获取相应节点
/// 关于xpath可以参见:
/// </summary>
public class Xml
{
private string FileName;
public Xml(string filename)
{
this.FileName = System.Web.HttpContext.Current.Server.MapPath(filename);
}
public void AddNode(string NodeName,string value){
//先建立一个XML DOM
XmlDocument doc = new XmlDocument();
//读入XML文件
doc.Load(FileName);
//建立一个节点。
XmlElement newChild = doc.CreateElement(NodeName);
newChild.InnerText = value;
doc.DocumentElement.AppendChild(newChild);
doc.Save(FileName);
}
public void WriteNode(string id, string name, string value)
{
//先建立一个XML DOM
XmlDocument doc = new XmlDocument();
//读入XML文件
doc.Load(FileName);
//获取XmlNode
XmlNode node = this.GetNodeById(doc, id);
XmlElement newChild = doc.CreateElement(name);
newChild.SetAttribute("id", id);
newChild.InnerText = value;
doc.DocumentElement.InsertAfter(newChild, node);
if (node != null)
{
doc.DocumentElement.RemoveChild(node);
}
doc.Save(FileName);
}
public static System.Collections.Specialized.NameValueCollection GetXMLValues(string XmlFile)
{
XmlDocument doc = new XmlDocument();
//读入XML文件
doc.Load(XmlFile);
//建立一个节点。
XmlNodeList ChildList = doc.DocumentElement.ChildNodes;
System.Collections.Specialized.NameValueCollection result = new System.Collections.Specialized.NameValueCollection();
后面还有 68 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。