Hi guys,
My app uses two XML documents for storing data. What I am trying to do is to store the XmlNodeLists in each document in the Cache so that the xml document doesnt have to be loaded every time the page is requested.
However, I come across a problem whne trying to retrieve the XmlNodeList from the cached object, as I get the error "Cannot implicitly convert type 'object' to 'System.Xml.XmlNodeList'. An explicit conversion exists (are you missing a cast?)"
The lines are as follows (the second line returns the error):
The function Utility.GetXmlNodes is just a function for dynamically loading an XmlNodeList based on given parameters, it looks like this:
Any help or advice would be much appreciated.
My app uses two XML documents for storing data. What I am trying to do is to store the XmlNodeLists in each document in the Cache so that the xml document doesnt have to be loaded every time the page is requested.
However, I come across a problem whne trying to retrieve the XmlNodeList from the cached object, as I get the error "Cannot implicitly convert type 'object' to 'System.Xml.XmlNodeList'. An explicit conversion exists (are you missing a cast?)"
The lines are as follows (the second line returns the error):
Code:
HttpContext.Current.Cache["myXmlNodes"] = Utility.GetXmlNodes("Products.xml", "PRODUCTS/PRODUCT");
myXmlNodes= HttpContext.Current.Cache["myXmlNodes"];
The function Utility.GetXmlNodes is just a function for dynamically loading an XmlNodeList based on given parameters, it looks like this:
Code:
// GetXMLNodes: Returns an XmlNodeList from specified parameters
public static XmlNodeList GetXmlNodes(string docString, string structString)
{
XmlDocument doc = new XmlDocument();
doc.Load(GetHomeDir() + GetXmlDir() + docString);
return doc.SelectNodes(structString);
}
Any help or advice would be much appreciated.