...

View Full Version : Copying an external XML file (using ASP)



BigEric
04-20-2007, 01:34 AM
I apologize in advance for probably asking a very newbie type question. I would imagine my query is simple, yet with all my years of developing, I have done very little work with XML - simply a factor of the projects I work on.

So here goes....

I was given a URL of an external xml file. Let's call it www.anyurl.com/file.xml

I want to simply GET the file and copy the entire file onto our server.

I have code that includes this:

set objHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "GET", "http://www.anyurl.com/file.xml", false
objHTTP.send

I can get the contents of the file and read the response text. However, this is not what I want to do. I want to read this external file (just as if it was a flat file) and make an exact duplicate of the file for saving on my server.

Any simple ways to do this? Whatever help anyone can offer would be tremendously appreciated.

Thank you in advance.

Eric :confused:

david_kw
04-20-2007, 03:13 PM
You might want to try getting this thread moved to the ASP forum. It doesn't appear to be an XML question at all since you just want to move it as a flat file.

Sorry I can't help. I know very little about ASP.

Good luck.

david_kw

BigEric
04-20-2007, 03:18 PM
Thanks David.

Is there a fast way to transfer this to the ASP forum?

david_kw
04-20-2007, 03:46 PM
Honestly, I haven't done it yet so I'm not positive. It sounds like you can private message a moderator and they will do it for you. The moderator for this board is Alex Vincent

http://www.codingforums.com/member.php?u=7

If you don't get a timely response, I've seen people create a new post in the new forum and say they were recommended to move this question and link back to this post.

Hopefully the moderator can take care of it for you. I'm afraid not sure if you can PM just this boards moderator or any.

david_kw

Alex Vincent
04-20-2007, 08:35 PM
I've just moved this thread. I wasn't sure about the move until you requested it. :)

BigEric
04-20-2007, 08:38 PM
Thank you Alex!!!

david_kw
04-22-2007, 04:37 AM
Hopefully someone here knows an actual answer but just in case here is some stuff to read about that might help.

http://forums.devshed.com/delphi-programming-90/download-a-file-196846.html
http://www.aurigma.com/Support/DocViewer/2/WorkingwithURL.htm.aspx
http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET13/aspnet13-05.aspx

david_kw

Basscyst
04-25-2007, 01:45 AM
Getting the response text from an xmlhttp request is an exact copy of the file as it is served.

If you need to put that data in a file on your server, all you need to do is create a text file using the file system object (http://www.w3schools.com/asp/asp_ref_filesystem.asp), give it a xml file extension and write the contents of your response text to the file you created. Now you have an exact copy of the xml file.

5 cents worth, free of charge:

If the xml file is always available at the remote url, it can be read, parsed and displayed from that location at anytime and the data thearin will be as up to date as possible. Unless you have need to keep an archive of the provided data, I see no benefit to saving a copy to your server's file system.

Basscyst

FishyFish
10-27-2011, 11:42 AM
Hi,

Sorry to bump an old thread - it came up on Google while I was searching on how to do this.

I need to use classic ASP to copy an XML rss file from an external website and save it on my own server in a writeable folder. Would anyone be kind enough to tell me how I can do this please?

I've read the posts above, but am still unsure how to put everything together to achieve this. Any help is much appreciated.

e.g. I want to take an exact copy of http://website.com/example_rss.xml and save it to \\MyServer\WriteableFolder\XMLcopy\

Thanks in advance!

Old Pedant
10-27-2011, 05:48 PM
<%
Set xml = Server.CreateObject("msxml2.ServerXMLHTTP")
xml.open( "GET","http://website.com/example_rss.xml")
xml.send( )

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set outfile = fso.CreateTextFile("\\MyServer\WriteableFolder\XMLcopy\example_rss.xml")

outfile.write xml.responseText

outfile.close( )
%>


Caution: The writable folder must be writable by the user IUSR_xxx where xxx is the name of the computer you run this script on. Being writable by your personal account would not help.

FishyFish
10-28-2011, 10:19 AM
<%
Set xml = Server.CreateObject("msxml2.ServerXMLHTTP")
xml.open( "GET","http://website.com/example_rss.xml")
xml.send( )

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set outfile = fso.CreateTextFile("\\MyServer\WriteableFolder\XMLcopy\example_rss.xml")

outfile.write xml.responseText

outfile.close( )
%>


Caution: The writable folder must be writable by the user IUSR_xxx where xxx is the name of the computer you run this script on. Being writable by your personal account would not help.

Thanks, that works a treat. I had to remove the paretheses around the xml.open statement though, otherwise if threw up an error.

Once again, many thanks. Much appreciated!

Old Pedant
10-28-2011, 08:21 PM
Sorry about the parentheses. Too much work with JavaScript and C# lately.

chukcha
11-19-2011, 08:54 AM
Sorry about the parentheses. Too much work with JavaScript and C# lately.

Yeah man I know what you mean. I always get mixed up between several platforms C#, JS, PHP =)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum