VC++ and XML, I want to retrieve an XML file from a URL 
Author Message
 VC++ and XML, I want to retrieve an XML file from a URL

I have VC++ 6.0, NT 4.0 Workstation, IE 5 and the MS XML parser.

 I have two questions.

1) What syntax can I use from VC++ to go to a given URL, pass 3 parameters to it  and retrieve an
XML data file. I am assuming that the URL is not changing.

2) To make it simple, in VC++ I want to write that data file I retrieved to an ascii file.

Please be specific in how to do this. Assume that the URL is www.seldin.com/xmlinfo.xml
So that the call might be something like this:

        www.seldin.com/xmlinfo.xml, parm1, parm2, parm3

PLease include a complete small program with appropriate "include files". Also, can I use the MFC
application wizard to create my shell program?

Thanks for your help.

PS. What would be the best newsgroup for XML with VC++.

Lawrence M. Seldin, CMC, CPC
Author of POWER TIPS FOR THE APPLE NEWTON and INTRODUCTION TO CSP



http://www.*-*-*.com/



Tue, 22 Jan 2002 03:00:00 GMT  
 VC++ and XML, I want to retrieve an XML file from a URL
See below...



Quote:
> I have VC++ 6.0, NT 4.0 Workstation, IE 5 and the MS XML parser.

.
.
.
Quote:
> 1) What syntax can I use from VC++ to go to a given URL, pass 3 parameters

to it  and retrieve an
Quote:
> XML data file. I am assuming that the URL is not changing.

> 2) To make it simple, in VC++ I want to write that data file I retrieved
to an ascii file.

> Please be specific in how to do this. Assume that the URL is

www.seldin.com/xmlinfo.xml
Quote:
> So that the call might be something like this:

> www.seldin.com/xmlinfo.xml, parm1, parm2, parm3

> PLease include a complete small program with appropriate "include files".

Also, can I use the MFC

Quote:
> application wizard to create my shell program?

First of all, it is probably easier to do a plain old internet file transfer
if all you are doing is copying the XML file from one place to another
(which it sounds like you are).  That way you don't pull in all the MSXML
baggage.  However, since you probably have your reasons, here is the code
simply to get and save the file using MSXML.  One thing to note: unless you
know that the XML file contains only ASCII characters, do not expect an
ASCII file to be saved.

Also, I have no idea what those thre parameters might be doing, so tis is
just the basic code to get and save the file.

I forget which of these headers I added and which were added by the New
Project Wizard...

#include <hlink.h>
#include <dispex.h>
#include <msxml.h>
#include <winnls.h>
#include <urlmon.h>

        IXMLDOMDocument            *pXMLDoc = NULL;

        HRESULT hr = ::CoCreateInstance( CLSID_DOMDocument, NULL,
CLSCTX_INPROC_SERVER,
                                         IID_IXMLDOMDocument,
(void**)&pXMLDoc );
        if ( SUCCEEDED(hr) )
        {
            //  You should really check ALL HRESULTs
            hr = pXMLDoc->put_async(VARIANT_FALSE);
            hr = pXMLDoc->put_validateOnParse(VARIANT_FALSE);  // Use
VARIANT_TRUE here if you want validation

            VARIANT vURL;
            VariantInit(&vURL);
            vURL.vt = VT_BSTR;
            V_BSTR(&vURL) = AsciiToBSTR( "www.seldin.com\\xmlinfo.xml" );

            // Load the document
            hr = pXMLDoc->load(vURL, &vb);
            VariantClear( &vURL );

            V_BSTR(&vURL) = AsciiToBSTR( lpszPathName );

            // Save the document
            HRESULT hr = pXMLDoc->save( vURL );
            VariantClear( &vURL );

            pXMLDoc->Release();
        }

Quote:
> Thanks for your help.

> PS. What would be the best newsgroup for XML with VC++.

microsoft.public.xml
microsoft.public.windows.inetexplorer.ie5.programming.xml

if you are interested in MSXML.

The above code was cut from several places in a large program, so I hope it
hangs together as a single method.  If not, it should be obvious what you
need to do.

Dave Richards



Tue, 22 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC++ and XML, I want to retrieve an XML file from URL

2. creating xml schema programmatically from an an xml file without using ADO.NET

3. how to retrieve records from an XML file

4. Retrieving data from a XML file on the web

5. how to retrieve records from an XML file?

6. Wanted-- Sample XSLT for XML Comments File (please)

7. hwo to convert value which get from xml to type which get from xml also

8. XML DOM and .NET's XML classes

9. XML.NET to XML.ADO26

10. Display XML in DataGrid from a URL

11. retrieve XML data from SQL server by using XSD mapping schema

12. Retrieving elements from xml documents

 

 
Powered by phpBB® Forum Software