using System.Web;
public string GetLeaderInfo(string symbol)
{
//获取高管信息的路径
XElement ele = XElement.Load("path.xml");
string path = ele.Element("leader").Value;
//首次读取缓存
string jsoncache = HttpRuntime.Cache.Get(symbol) as string;
if (jsoncache == null || jsoncache.Equals(""))
{
//读取数据
XmlDocument doc = new XmlDocument();
doc.Load(path);
string strSearch = "root/高管信息[@代码='" + symbol + "']";
XmlNode searchNode = doc.SelectSingleNode(strSearch);
XmlElement element = (XmlElement)searchNode;
xmltoJson json = new xmltoJson();
jsoncache = json.XmlToJSON(element);
//加缓存
HttpRuntime.Cache.Insert(symbol, jsoncache, null, DateTime.UtcNow.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);
}
return jsoncache;
}