using System.Xml;
using System;
using System.Text;
using System.Net;
using System.Collections;
using System.Collections.Generic;
public class xml
{
public static string read( string path,string val1,string val2)// str1 文件位置 str2 父节点 str3 子节点
{
XmlDocument xml =new XmlDocument();
xml.Load(path);
XmlNode root=xml.SelectSingleNode(val1);
string val=(root.SelectSingleNode(val2)).InnerText;
return val;
//返回子节点属性
}
}
demo:
var path=Server.MapPath("~/App_Data");
path=path+"/ts.xml";
string user=xml.read(path,"/xml","CreateTime");
@user