Link to home
Start Free TrialLog in
Avatar of ols2
ols2

asked on

using asp and Microsoft.XMLDOM

Hi,
I have a code snippet, like this:

<%
            set xml = Server.CreateObject("Microsoft.XMLDOM")
            xml.async = false
            xml.load("http://popit.inpoc.com/popit.inpoc.com/xml_pull.vsp?type=P&size=10")
            set xsl = Server.CreateObject("Microsoft.XMLDOM")
            xsl.async = false
            xsl.load("http://www.popit.no/html_new/html/sms/xml/ringtones.xsl")
           Response.Write(xml.transformNode(xsl))
Set objXML = Nothing
%>

It all works briliantly, up to  apoint, when it stops working all together.
The asp pages just loads and loads, and nothing happens, until i reboot the server.

I use iis5
ASKER CERTIFIED SOLUTION
Avatar of alambres
alambres

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ols2
ols2

ASKER

DOH !!!!
*blushing*  oh well......
Thankyew !
ya welcome!  glad to be helpful.

peace

alambres
Avatar of ols2

ASKER

Oh sorrow, it is back!!!!

my code now look like this:
<%
            set xml = Server.CreateObject("Microsoft.XMLDOM")
            xml.async = false
            xml.load("http://popit.inpoc.com/popit.inpoc.com/xml_pull.vsp?type=JAVA&size=3")
            set xsl = Server.CreateObject("Microsoft.XMLDOM")
            xsl.async = false
            xsl.load("http://www.popit.no/html_new/html/sms/xml/topgames.xsl")
            Response.Write(xml.transformNode(xsl))
                  set xml = nothing
                  set xsl = nothing
%>


After running the code for a number of times, it just loads, and nothing happens. The onlu solution is, again to reboot the box.
I am becoming suicidal! Help !! Anyone????
I don't see what's wrong in ya code. Maybe the problem is the server configuration
Avatar of ols2

ASKER

Now, i have found that emediately before things go kaplooey, i receive this error:

Microsoft VBScript runtime error '800a01fb'

An exception occurred: 'xml.load'

/html_new/html/sms/xml/sms_2_copy(1).asp, line 4

Haven't seen this before, probably because someone else on the site got it first.
Ring any bells?
Avatar of ols2

ASKER

The new development is:

I can access the file 21 times.
On the 22 time:
Microsoft VBScript runtime error '800a01fb'

An exception occurred: 'xml.load'

/html_new/html/sms/xml/sms_2_copy(1).asp, line 4


I am baffled......
It's an easy fix.  There are bugs with HTTP access on the server with that old version of the parser.  Use this instead:

<%
            set xml = Server.CreateObject("Msxml2.DomDocument")
            xml.async = false
            xml.setProperty "ServerHTTPRequest", true
            xml.load("http://popit.inpoc.com/popit.inpoc.com/xml_pull.vsp?type=JAVA&size=3")
            set xsl = Server.CreateObject("Msxml2.DomDocument")
            xsl.async = false
            xsl.setProperty "ServerHTTPRequest", true
            xsl.load("http://www.popit.no/html_new/html/sms/xml/topgames.xsl")
            xml.transformNodeToObject xsl, Response
               set xml = nothing
               set xsl = nothing
%>

See:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmpro2nd_serverhttprequest.asp

You should not use Microsoft.XMLDOM on the server at all, and expecially when attempting to load over HTTP.  MSXML 3 (which is "Msxml2.DomDocument:) won't even try to use HTTP for a load on the server, unless you set the ServerXMLHTTP.

Also, note my use of the transformNodeToObject method.  This uses IStream; it's faster than strings/response.write and safer since it preserves the encoding.

Regards,
Mike Sharp
By the way, if you have MSXML 4 on the server, use it instead.  It's even faster than MSXML 3.

            set xml = Server.CreateObject("Msxml2.DomDocument.4.0")


If the XSL file is on the same server that your ASP is on, use the Server.MapPath method to load:

xsl.load(Server.MapPath("/html_new/html/sms/xml/topgames.xsl"))

or whatever relative virtual path you need to point to the XSLT.  If the XSL is on another site, then do it as my example before.

Make sure your XSLT uses the current namespace, too.  Microsoft.XMLDOM is very old, non conforming and buggy.

Regards,
Mike Sharp
Thank you all for discussion this matter, it has solved my problem.

I have tried to solve the problem by using MSXML4 with no success.

The problem was actually solved when I used MSXML 3 instead of MSXML 4, that is:

set xml = Server.CreateObject("Msxml2.DomDocument")

instead of

set xml = Server.CreateObject("Msxml2.DomDocument.4.0")

I experienced that loading one URL worked in MSXML4 and another did not. They both worked with MSXML3...weird, eh?

/Christian
Yes, that's quite weird.  

Mike