PDA

View Full Version : Retrieving XML file to parse


tae_mike
11-05-2003, 08:35 AM
I'm new to ASP and XML, but I'm working on a project that requires it. I've found several samples to retrieve the data, but I can't seem to get any to work.

I have an ASP page that has two variables to post to a website
http://www.testserver.com/report?partno=12345&vehicleno=12345

they require authentication with username and password.

Then they return an XML file. <xml><vehicles><vehicle name=""></vehicle></vehicles></xml>

I need to save the xml file to a subdirectory, then start parsing the xml file.

According to some of the articles, I'm supposed to use winhttp to do the authentication because the asp is run on the server. Then, I'm supposed to use msxml to parse and get my info.

Can someone get me started? Maybe provide an example of what to use to do the request followed by how to display the name value? I'd be willing to pay if I need to.

Thanks!

Mike

tae_mike
11-05-2003, 09:43 AM
This is what I have so far. I don't have the component registered yet, so I'm getting that error.

Otherwise, does this look ok? I'd like to generate the URL dynamically so I can fill in the part info and I need to send the username and password.

(one.asp)
<%@language=JScript%>
<%
var srvXMLHTTP
srvXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP");
srvXMLHTTP.open ("POST", "http://animal1:password2@mytestserver.com/report?partno=343201&vehicleno=284071", false);
srvXmlHttp.send();
partsElement = srvXMLHTTP.responseXML.selectSingleNode("/VEHICLES/VEHICLE/");
%>

<html>[b]<p>First Element<p>
<%Response.Write(partsElement.text);%>
</body></html>