Link to home
Create AccountLog in
Avatar of Dirar Abu Kteish
Dirar Abu KteishFlag for Palestine, State of

asked on

Load xml with asp extension

Hi,

I am trying to load an xml file with asp extension, i.e sqlXml.load("path/myfile.asp")... It's working fine when the extension is xml, but I have problem loading it with asp extension.
I know that the problem is because I am trying to load the asp file from a physical path and not through HTTP, but I am not sure how to load the xml from HTTP cuz I am loading the xml from global.asa and the path is not always the same...

appreciate any help

Thanks
Avatar of Badotz
Badotz
Flag of United States of America image

So, why change the extension from .xml to .asp? Leave it alone!
Avatar of B_Dorsey
B_Dorsey

before the
sqlXml.load("path/myfile.asp")

put
sqlXml.setProperty "ServerHTTPRequest", true

and make sure you include the http://mydomain.com/mypath/to/the/asp/file.asp
Yeah, but if it ain't broke, why fix it?
i think what he is saying is that he has tried using a xml file and it works but as soon as he tried to create a dynamic XML file with ASP it doesnt work, but he knows for the ASP to execute correctly it has to be called via http

b
gotcha - well, until we hear back from dxz2, we won't know what he is thinking ;-)
Avatar of Dirar Abu Kteish

ASKER

Hi,

I will try B_Dorsey suggestion tomorrow at work.
Why changing xml to asp? because there is sensitive data inside the xml file and I created some kind of server side authentication to disable xml file to be directly viewed in browsers

B_Dorsey what do you mean by "and make sure you include the http://mydomain.com/mypath/to/the/asp/file.asp"

Thanks

-dirar
>> cuz I am loading the xml from global.asa

That is pretty secure, no?
Hi B_Dorsey,

This is what I am doing:

Set sqlXml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
path = Server.MapPath("../../xml/DBQUERY.xml")
sqlXml.setProperty "ServerHTTPRequest", true
sqlXml.load path

did not work

I then added:
sqlXml.async = false
sqlXml.validateOnParse = false

And it worked

Thanks a lot the sqlXml.setProperty was I am missing
:) my bad I am sorry

no it didn't work till now I thought I changed the path
should be
path = Server.MapPath("../../xml/DBQUERY.asp")


any suggestions
a ASP page needs to be executed.. I didnt know you could use ../ in Server mappath... so try the suggestions below...


Set sqlXml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
sqlXml.setProperty "ServerHTTPRequest", true
sqlXml.Load Server.MapPath("/xml/DBQUERY.asp")

Set sqlXml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
sqlXml.setProperty "ServerHTTPRequest", true
sqlXml.Load Server.MapPath("http://www.mydomain.com/xml/DBQUERY.asp") 'Replace my domain with the domain name

I get "Invalid xml declaration" I think this is because of the <%%> in asp

-dirar
ASKER CERTIFIED SOLUTION
Avatar of B_Dorsey
B_Dorsey

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
I gad to start the document with
<?xml version="1.0" encoding="utf-8"?>

instead with <%%>

and it worked

thanks