在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
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; } |
请发表评论