6 Ocak 2014 Pazartesi

Xml Caching

How can We Cache Xml?
Answer =>

using (XmlTextReader xmlReader1 = new XmlTextReader("c:\\users/can.canbek/documents/visual studio 2012/Projects/EcPiyasalarList/EcPiyasalarList/DelayDBMatriks.xml"))
            {
                XmlDocument xmldoc1 = new XmlDocument();
                xmldoc1.Load(xmlReader1);
                XmlNode topnode1 = xmldoc1.DocumentElement;
                if (HttpRuntime.Cache[xmldoc1.ToString()] == null)
                {
                    HttpRuntime.Cache.Add(xmldoc1.ToString(), xmldoc1, null, DateTime.Now.AddMinutes(15), TimeSpan.Zero,
                        CacheItemPriority.Default, null);
                }
                else
                {
                    xmldoc1 = (XmlDocument)HttpRuntime.Cache[xmldoc1.ToString()];
                }
}

Force Be With You...

Hiç yorum yok:

Yorum Gönder