Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
|
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2004, 04:00 PM
Authorized User
 
Join Date: Nov 2004
Posts: 57
Thanks: 0
Thanked 0 Times in 0 Posts
Default Saving XML HELP!!!

I am posting form information to a site that returns an xml page with data that our company needs. I am very new to the XML world, and I don't understand how to automatically save the returned xml page locally.

Since the returned page requires form data, I cannot do the following:

xml.Open "GET", "http://www.somesite.com", False

which is common on all of the examples I have seen on the net.
I would like our intranet users to be able to click on a page; it sends the form data, saves the returned page, and then runs a parser to consume the data.

Can someone please help me?
 
Old November 23rd, 2004, 12:27 PM
Registered User
 
Join Date: Mar 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is what you do:

Use your appropriate MSXML Object, then use store the returned XML (from get or post) into a variable. Use the FileSystem Object to write the XML locally (hence cached XML). You can they reference the file into your transform code for XSL., You can also directly parse the stored XML in the variable. Warning: its a little slow!!

Sample code:

        Dim file_out1, objXMLHttp1, response_xml1
        Set objXmlHttp1 = Server.CreateObject("Msxml2.ServerXMLHTTP")
        objXmlHttp1.open "GET", YOUR_url & "YOUR PARAMETERS", False
        objXmlHttp1.send
        response_xml1 = objXmlHttp1.responseXML

NOW transform with XSL:

    Set objXML = Server.CreateObject("Microsoft.XMLDOM")
    objXML.async = False
    objXML.Load(response_xml1)

    Set objXSL = Server.CreateObject("Microsoft.XMLDOM")
    objXSL.async = false
    objXSL.load("YOUR location of XSL file - absolute URL")
    xmlResponseDoc = objXML.transformNode(objXSL)


and thats it.


 
Old November 23rd, 2004, 12:34 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

This function retrieves any sort of file from the web:
Code:
function saveRemoteFile(From, To)
{
  var oXmlHttp = new ActiveXObject("Msxml2.XmlHttp.4.0");  //Change to version 3 if necessary
  oXmlHttp.open("GET", From, false);
  oXmlHttp.send();
  if (oXmlHttp.status == 200)
  {
    var oStream = new ActiveXObject("Adodb.Stream");
    oStream.type = 1; //Binary
    oStream.open();
    oStream.write(oXmlHttp.responseBody);
    oStream.saveToFile(To, 1 && 2); 
    oStream.close();
  }
  else
  {
    throw new Error(oXmlHttp.statusText);  //Needs improving
  }
}

saveRemoteFile("http://www.google.com", "C:\\myFolder\\myGooglePage.htm");
If you know the data is going to be XML then once you have opened and sent you can just do:
Code:
//create msxml2.xmlhttp.4.0, open and send
oXmlHttp.responseXML.save(<path to save to>);

--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving DataView as XML unprsandeep ADO.NET 9 May 26th, 2007 02:12 AM
saving xml in asp.net using schema kavifs ASP.NET 1.0 and 1.1 Professional 0 February 23rd, 2007 10:32 AM
Translating a XML with XSL and saving results DevOne XML 1 April 9th, 2005 07:32 AM
help with saving Collection to XML alevey VB.NET 2002/2003 Basics 2 December 22nd, 2003 08:34 PM
saving xml shine Classic ASP XML 1 July 22nd, 2003 08:12 AM





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