xslt - Loading XML using a HTTP GET request in classic ASP -
i'm working on old software written in classic asp (vbscript).
i should create asp page makes xsl transformation. i'm able using static files have work xml files dynamically generated asp pages (this doesn't work).
this code:
dim document, stylesheet, o set document = server.createobject("msxml2.domdocument") document.async = false set o = createobject("msxml2.xmlhttp") o.open "get", "http://localhost/aaa/cgi-bin/fo/file.asp?id_x=39", false o.send 'document.load server.mappath("test.xml") ' <- static file working 'document.loadxml(o.responsetext) ' <- not working document.load o.responsexml ' <- not working set stylesheet = server.createobject("msxml2.domdocument") stylesheet.async = false stylesheet.load server.mappath("test.xslt") 'response.write o.responsetext ' <- working! (return correct xml) 'response.write o.responsexml.xml ' <- not working (empty result) response.write document.transformnode(stylesheet) set document = nothing set stylesheet = nothing
all running on virtual machine windows 2000 server (unfortunately need in way).
thank help.
this quick stab (untested).
based on have, i've made minor changes. don't need declare msxml2.domdocument
object, using set document = o.responsexml
same effect. added http status code check capture issues.
looking @ line;
document.load o.responsexml
this not work because load()
method expects file location.
dim document, stylesheet, o 'should using iserverxmlhttprequest object set o = server.createobject("msxml2.serverxmlhttp.6.0") o call .open("get", "http://localhost/aaa/cgi-bin/fo/file.asp?id_x=39", false) call .setrequestheader("content-type", "application/xml; charset=utf-8") call .send() if .status = 200 set document = o.responsexml else 'handle errors end if end set stylesheet = server.createobject("msxml2.domdocument") stylesheet.async = false stylesheet.load server.mappath("test.xslt") response.write document.transformnode(stylesheet) set document = nothing set stylesheet = nothing
Comments
Post a Comment