Click here to Skip to main content
Licence CPOL
First Posted 17 Apr 2003
Views 53,594
Downloads 100
Bookmarked 23 times

How to load a tree view with a large XML file (Pocket PC version of Frank Le's program)

By | 17 Apr 2003 | Article
Using XML on the Pocket PC is almost as easy as on a Desktop. You only need to make a few magic calls and voila, you have it!

Sample Image - CETreeView.jpg

Introduction

This is the Pocket PC version of Frank Le's, "How to load a tree view with a large XML file". I got permission from Frank to post the CE or Pocket PC version of his program. It's been a couple of months after I implemented the Pocket PC version and never had time, until now, to document and upload it. It's now over a year later, so here goes.

Initializing COM:

hr = CoInitializeEx(NULL,COINIT_MULTITHREADED);

Next, the following bit of code must be executed. But I don't remember why. It's something about document safety options. If someone does know, please post the reason.

/* Pocket PC workaround:
    Remove document safety options  */
 
 IObjectSafety* pSafety;
 DWORD  dwSupported, dwEnabled;
 if ( SUCCEEDED(document->QueryInterface( IID_IObjectSafety,
       (void**)&pSafety ) ) )
 {
  pSafety->GetInterfaceSafetyOptions(MSXML::IID_IXMLDOMDocument, 
     &dwSupported, &dwEnabled );
   pSafety->SetInterfaceSafetyOptions(MSXML::IID_IXMLDOMDocument,
     dwSupported, 0 );
 }

The following code uses the FileStream to load an XML file into the DOM. You need to get the FileStream.h file for this (included in the zip file).

VARIANT    vXMLSrc;
 VARIANT_BOOL   vSuccess;

 VariantInit( &vXMLSrc );

 /* to load an XML file from a local file use the following code */
 FileStream* fs = new FileStream;
 fs->open(strPathName);
 vXMLSrc.punkVal = fs;
 vXMLSrc.vt = VT_UNKNOWN;
 hr = document->load(vXMLSrc, &varOkay);
 if (FAILED(hr))
  return FALSE;

Lastly,

node->hasChildNodes()

is replaced with:

VARIANT_BOOL vbHasChild;
  node->hasChildNodes(&vbHasChild);
  if (vbHasChild) {

I have forgotten why, and it may not be necessary. The code does work though. I have included an ARM exe with the zip file.

I used the DOM in some of my programs here and it worked pretty well.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

mark edwards



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionhow to make the application available for dialog? Pinmembertianbawudiku3:12 30 Jun '06  
GeneralFlash Drive Pinmemberauburnate5:43 26 May '04  
GeneralSample Pinmemberponshio7:23 18 Sep '03  
GeneralMy experience ... PinmemberDaniel S.6:44 19 Apr '03  
Generalno ARM exe in zipfile! Pinmemberferdo7:52 18 Apr '03  
GeneralRe: no ARM exe in zipfile! Pinmembermark edwards8:02 18 Apr '03  
GeneralDynamic updating of tree with new data PinmemberJRubinstein8:30 19 Aug '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120528.1 | Last Updated 18 Apr 2003
Article Copyright 2003 by mark edwards
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid