Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml and asp 1

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
Hi,

I want to get data from a remote database.
Have created an asp file that when run outputs XML in the following format

Code:
  <?xml version="1.0" encoding="ISO-8859-1" ?> 
- <car>
  <vehicleidK>12345</vehicleidK> 
  <registrationnumberK>REG</registrationnumberK> 
  <descriptionK>Astra 5Dr HAT 1.6i VVT SXi</descriptionK> 
  <motduedateK>2008-9-14</motduedateK> 
  <nextservicedateK>2009-1-1</nextservicedateK> 
  <lastknownmileageK>25773</lastknownmileageK> 
  <aftersalesbranchK>001</aftersalesbranchK> 
  <servhistory>Historyservhistory> 
  </car>

How do I get the data above back from the server?
Do I have to run the ASP file and save it as XML file on the remote server and then read the XML file?
Cant I run the file and get the result without saving a file 1st?

I am trying to use the following code to retrieve the file
but doesnt work
Code:
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("carlookup.asp?reg=" & x_reg))
 
I think you need to look at Ajax. Most of it will be in Javascript but it is quite easy to convert to VBScript.
 
You can load the xml directly. do not user server.mappath because the load will then try to load a file carlook.asp?reg= etc.

Code:
      set xmlDoc = createObject("MSXML2.DOMDocument")
      xmlDoc.async = False
      xmlDoc.setProperty "ServerHTTPRequest", true
      xmlDoc.load("[URL unfurl="true"]http://url/carlook.asp?reg="&x-reg)[/URL]
 
hi - thanks for your replies

foxbox - tried this but cannot get a response

code looks like
Code:
      set xmlDoc = createObject("MSXML2.DOMDocument")
      xmlDoc.async = False
      xmlDoc.setProperty "ServerHTTPRequest", true
      xmlDoc.load("[URL unfurl="true"]http://localhost/mysite/carlookup.asp?reg="&x_reg)[/URL]

' Parse XML
if xmlDoc.parseError.errorcode <> 0 then  ' oops error in xml  
Response.Write("XML Error...<br>")
else  ' get xml data  
Response.Write(xmlDoc.documentElement.childNodes(0).attributes.getNamedItem("vehicleidK").nodeValue)
end if

I just get the parse error

xwb - AJAX is just a technique for running my asp page, might try and get this call to run this way later
 
apologies - works fine (my fault, wasnt getting x_reg)
thankyou foxbox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top