I currently have the function below which I use for pulling data out of an XML file. I use this many times around the site.
The problem is, the XML document rarely changes, but the system has to load it all in every time it wants to use it.
Is there any way of creating a global XML document that is only read in once and just referenced with this function instead?
Dim oContent As New XmlDocument
oContent.Load(HttpContext.Current.Server.MapPath("/includes/content/content.xml"))
Try
Return oContent.SelectSingleNode("/xml/Contents/Content[attribute::title='" & sTitle.ToLower & "']").InnerText.Replace("<", "<").Replace(">", ">")
Catch ex As Exception
Return ""
End Try
oContent = Nothing
Thanks
Ben
-- Please mark my responses as answers if they help!
ferretneck
Member
601 Points
279 Posts
XMLDocument Load
Feb 21, 2012 03:55 PM|LINK
Hi
I currently have the function below which I use for pulling data out of an XML file. I use this many times around the site.
The problem is, the XML document rarely changes, but the system has to load it all in every time it wants to use it.
Is there any way of creating a global XML document that is only read in once and just referenced with this function instead?
Dim oContent As New XmlDocument oContent.Load(HttpContext.Current.Server.MapPath("/includes/content/content.xml")) Try Return oContent.SelectSingleNode("/xml/Contents/Content[attribute::title='" & sTitle.ToLower & "']").InnerText.Replace("<", "<").Replace(">", ">") Catch ex As Exception Return "" End Try oContent = NothingThanks
Ben