Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Copying an external XML file (using ASP)

    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

  • #2
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks David.

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

  • #4
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #5
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts
    I've just moved this thread. I wasn't sure about the move until you requested it.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #6
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Alex!!!

  • #7
    Senior Coder
    Join Date
    Nov 2006
    Posts
    1,000
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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-pro...le-196846.html
    http://www.aurigma.com/Support/DocVi...thURL.htm.aspx
    http://msconline.maconstate.edu/tuto...pnet13-05.aspx

    david_kw

  • #8
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    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, 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
    Helping to build a bigger box. - Adam Matthews

  • #9
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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!

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    Code:
    <%
    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.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    FishyFish (10-28-2011)

  • #11
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Code:
    <%
    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!

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,200
    Thanks
    75
    Thanked 4,342 Times in 4,308 Posts
    Sorry about the parentheses. Too much work with JavaScript and C# lately.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #13
    New Coder
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Old Pedant View Post
    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 =)
    When talking about energy Cordyceps > Coffee


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •