p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP XML (http://p2p.wrox.com/forumdisplay.php?f=69)
-   -   use asp to get data from xml (user defined) (http://p2p.wrox.com/showthread.php?t=16954)

vivian62 August 17th, 2004 03:41 AM

use asp to get data from xml (user defined)
 
hi, I had write an asp file to get data from an xml named "data.xml" and below is the coding:

Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("data.xml"))
Dim fText1, fText2
fText1 = xml.documentElement.childNodes(0).text
fText2 = xml.documentElement.childNodes(1).text
Set xml = Nothing

It's all Ok and can run. But my problem here is I want to call an xml file that I don't know its name (not "data.xml"). The xml file pass by the user who call my asp file. The user can pass the xml via anything for example asp or VB component. So I will not know exactly what the name of the xml file.

Thanks.

Kabe August 18th, 2004 07:40 AM

you need this?

login + passw potional, i think u can leave them empty

dim objxml, url
url = "http://yourfile_thatreturn_a_valid_xml.asp"
set objxml = server.CreateObject("msxml2.xmlhttp.4.0")
objxml.open "get",url,false,"login","passw"
objxml.send

grzz
kabe.be

Kabe August 18th, 2004 07:44 AM

forgot this, to read ur xmlobject

value = objxml.responseXml.selectsinglenode("XPath").text

vivian62 August 18th, 2004 10:16 PM

Thanks Kabe for your help..

I would like to correct some mistakes that I had made in my post.
Actually the thing go like this:
--I need to create an asp that can called by other page that written by other people. The page that writen by other people can be anything for example asp and it contains the xml inside it. So the page will call my asp file then I need to grab data from it. The data that I retrieve is inside the particular element that I need.
For example I need to retrieve the data for username and password, so I just need to find the elements with <user> and <pwd> only inside the page that call my asp.
I will not consider element other that this. So the page must correctly put <user> other than <usr>.

So it is still suitable to put XMLHTTP?

Regards,
vivian





All times are GMT -4. The time now is 05:14 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.