[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

IE50 - XML Examples

  • From: Sung_Nguyen@d... (Sung Nguyen)
  • To: Tyler Baker <tyler@i...>, Fernando Cabral <fernando@p...>
  • Date: Fri, 6 Nov 1998 20:09:51 -0600

ixmldocument example
     Hi all:
     
     I have trouble with linking the following example (downloaded from 
     MicroSoft site)
     This is the link error I got:
     
     "G:\mssdk\lib\ole32.lib : fatal error LNK1106: invalid file or disk 
     full: cannot seek to 0x35cb1cf1"
     
     The two files: "mshtml.h" msxml.h" I got from Internet SDK with IE4.0
     I don't know if they are still compatible with IE5.0 and where I can
     get new "mshtml.h" msxml.h" for IE5.0.
     
     Please point me the direction,
     
     Thanks a lot,
     
     SeanN
     
     --------------------------------------
     
     //////////////////////////////////////////////////////////////////////
     //////
     // Sample1.cxx: XML Object Model Sample 1
     //--------------------------------------------------------------------
     ------
     // Copyright (c) 1998  Microsoft Corporation.  All Rights Reserved.
     //
     // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
     // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
     // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
     // PARTICULAR PURPOSE.
     //--------------------------------------------------------------------
     ------
     //////////////////////////////////////////////////////////////////////
     //////
     
     #include <windows.h>
     #include <windowsx.h>
     #include <stdlib.h>
     #include <stdio.h>
     #include <io.h>
     #include <hlink.h>
     #include <dispex.h>
     #include "mshtml.h"
     #include "msxml.h"
     #include <winnls.h>
     
     #define CHECKHR(x) hr = x; if (FAILED(hr)) goto Cleanup;
     #define SAFERELEASE(p) if (p) {(p)->Release(); p = NULL;} else ;
     
     //////////////////////////////////////////////////////////////////////
     //////
     // Synopsis: Create an IXMLElement of type t
     //////////////////////////////////////////////////////////////////////
     //////
     IXMLElement* CreateXMLElement(IXMLDocument* pDoc, XMLELEM_TYPE t)
     {
         IXMLElement* e;
         VARIANT type;
         type.vt = VT_I4;
         V_I4(&type) = t;
         VARIANT name;
     
         name.vt = VT_BSTR;
         V_BSTR(&name) = ::SysAllocString(L"ElementNode");
         HRESULT hr = pDoc->createElement(type, name, &e);
         ::SysFreeString(V_BSTR(&name));
     
         return e;
     }
     
     //////////////////////////////////////////////////////////////////////
     //////
     // Synopsis: Create an XML Document from Scratch in memory
     //////////////////////////////////////////////////////////////////////
     //////
     HRESULT MemDocument()
     {
         IXMLDocument           *pDoc = NULL;
         IStream                *pStm = NULL;
         IPersistStreamInit     *pPSI = NULL;
         IXMLElement            *enode = NULL, *el = NULL;
         IXMLElement            *root = NULL;
         LARGE_INTEGER li = {0, 0};
         HRESULT hr = S_OK;
         int i, j;
     
         // Create an empty XML document
         CHECKHR(CoCreateInstance(CLSID_XMLDocument, NULL, 
     CLSCTX_INPROC_SERVER,
                                     IID_IXMLDocument, (void**)&pDoc));
     
         // Query the IPersistStreamInit interface
         CHECKHR(pDoc->QueryInterface(IID_IPersistStreamInit, (void 
     **)&pPSI));
     
         // Create an IStream
         CHECKHR(CreateStreamOnHGlobal(NULL, TRUE, &pStm));
         pStm->AddRef();
     
         //
         // Create an xml document with a root element
         //
         ULONG ulWritten;
         CHECKHR(pStm->Write("<root/>", strlen("<root/>"), &ulWritten));
        
         // load the xml document
         CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
         CHECKHR(pPSI->Load(pStm));
     
         // get root element
         CHECKHR(pDoc->get_root(&root));
     
         //
         // Create an xml document in memory
         //
         for (i = 10; i > 0; i--)
         {
             enode = CreateXMLElement(pDoc, XMLELEMTYPE_ELEMENT);
             CHECKHR(root->addChild(enode, -1, -1));
     
             for (j = 10; j > 0; j--)
             {
                 el = CreateXMLElement(pDoc, XMLELEMTYPE_ELEMENT);
                 CHECKHR(enode->addChild(el, -1, -1));
                 SAFERELEASE(el);
             }
             SAFERELEASE(enode);
         }
     
     
         CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
         CHECKHR(pPSI->Save(pStm, TRUE));
     
         //
         // Load the document from the in-memory stream
         //
         CHECKHR(pStm->Seek(li, STREAM_SEEK_SET, NULL));
         CHECKHR(pPSI->Load(pStm));
     
     Cleanup:
     
         SAFERELEASE(root);
         SAFERELEASE(el);
         SAFERELEASE(enode);
         SAFERELEASE(pPSI);
         SAFERELEASE(pStm);
         SAFERELEASE(pDoc);
     
         return hr;
     }
     
     int _cdecl 
     main(int argc, char *argv[])
     {
         HRESULT hr = S_OK;
     
         CoInitialize(NULL);
     
         hr = MemDocument();
     
         CoUninitialize();
     
     
         return hr == 0 ? 0 : 1;
     }

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.