Automate saving an XML file displayed in a browser as a local file

Posted on 2008-11-12
Last Modified: 2013-11-27
Hi I would like to open a webpage that displays an XML file then save the content as a local XML file.

Using the 'Import XML' feature in Access works fine to a point but everytime I use the wizard it accesses the site 3 times...The problem is that I am limited to 9 webpage accesses a week (1 a day plus 2 xtra) and I want to carry out this process 5 times a week (each weekday).

Below is some cut down code based on a form with a webbrowser control

Dim URL As String
URL = ""
Me.WebBrowser2.Navigate URL
Me.Text3 = Me.WebBrowser2.Document.Body.outertext

This almost works but what i really need is the content from the view source.  Is this possible??
If I use Innerhtml instead of outertext I get a load of <Div> info etc.

Although the data is not included in the two wrongs and correct file I assume that the principal is the same for saving the source.  I have also attached an example data file for reference.
Question by:Jenkar
    LVL 44

    Expert Comment

    by:Leigh Purvis
    Examples of directly accessing web data (such has XML content) online... (uses MSXML object rather than an IE ActiveX control - a much lighter solution).
    LVL 44

    Accepted Solution

    Oh pants.  I'm sure that link method used to work... :-s
    (Was never very up to speed on it to be fair though).
    Rather than guess again... here's the full links.

    Author Comment

    Thank you just slightly modified code but works perfectly!


    Function fGetWebPost(strSourceURL As String)
        Dim xmlServerHttp As Object
        Set xmlServerHttp = CreateObject("MSXML2.ServerXMLHTTP.4.0")
        With xmlServerHttp
            .Open "POST", strSourceURL, False
            .setRequestHeader "Content-Type", "text/xml"
            .Send strRequest
            fGetWebPost = .responseText
        End With
        Set xmlServerHttp = Nothing
    End Function

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This article is a continuation or rather an extension from Cascading Combos ( and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now