[quoted text, click to view] "David Gagné" <gagne.david@sympatico.ca> wrote in message
news:OAAsRDkqDHA.3320@tk2msftngp13.phx.gbl...
> Hi,
> I'm using ASP on Windows 2K. I'm NOT using ASP.Net. I have static data
in an
> XML file that I would like to cache. Based on my idea explained below,
is it
> an approach that should scale correctly? Considering that the cache
will be
> used extensively, will this create a bottleneck?
>
> My idea is:
> In the application_OnStart(), I load the xml file and store the xml
string
> in an application variable:
> sub application_OnStart()
> ...
> myXmlDOM.Load("myfile.xml")
> Application("myXMLString") = myXmlDOM.xml
> ' Would have been insteresting to store the parsed xml in the
> application
> ' but it returns an error saying the object can't be stored in
> application variable
> ' because it has appartment threaded behaviors.
> ' Set Application("myXML") = myXmlDOM doesn't work
> ...
> end sub
>
> Then I create an asp file (cache.asp) that has functions to get
information
> from this xml string.
> function getName(theID)
> ...
>
> set oDs = Server.CreateObject("MSXML2.DOMDocument")
> ...
> if oDs.loadXML(Application("myXMLString")) then
> ...
> xpath = ... theID
> ' Get the value using selectSingleNode(xpath)
> ...
> end if
> set oDs = nothing
> end function
>
> function getID(theName)
> ...
>
> set oDs = Server.CreateObject("MSXML2.DOMDocument")
> ...
> if oDs.loadXML(Application("myXMLString")) then
> ...
> xpath = ... theName
> ' Get the value using selectSingleNode(xpath)
> ...
> end if
> set oDs = nothing
> end function
>
> Thanks for you advise,
> David.
Use the thread safe version to save the parsed document to an
Application variable:
MSXML2.FreeThreadedDOMDocument.4.0
As for bottlenecks, I imagine that you will actually see quite an
improvement in performance by using a cached document. Let me know how
it turns out.
Notes:
1. In the future, please indicate what version of MSXML you are using.
2. Consider using version specific ProgID's, as version independent
ProgID's have been deprecated
3. Consider using "NewParser":
DOM.setProperty("NewParser",True)
HTH
-Chris Hohmann