读取XML帮助类

时间:2021-10-07 14:34:30
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml; /// <summary>
///GetXML 的摘要说明
/// </summary>
public class GetXML
{
public GetXML()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
//地址是xml文件的地址,然后传入匹配项 看匹配项是否在xml中存在
public static bool XMLISTrue(string address, string cardId)
{
XmlDocument doc = new XmlDocument();
address = @"Ntours_GroupWeb\manager\FIT_Activity_Rule/" + address;
doc.Load(address); //加载Xml文件
XmlElement rootElem = doc.DocumentElement; //获取根节点
XmlNodeList typeNode = rootElem.GetElementsByTagName("type");
int num = ;
foreach (XmlNode node in typeNode)
{
if (node.Attributes["value"].Value.ToString()== "CheckCardId")
{
XmlNodeList visaNodes = node.ChildNodes;
foreach (XmlNode vnode in visaNodes)
{
if (cardId.Substring(, ) == vnode.InnerText)
{
num = ;
break;
}
else
{
num++;
}
}
}
}
if (num != )
{
return false;
}
else
{
return true;
} }
}