Hi,

I know that the documentation says if you use G++ you are on your own, however after revisiting C++ (from a 6 year hiatus), I was hoping to find some examples the compiled out of the box, when I slapped them into a new file.

Some examples are missing a namespace declaration (which I had to do some digging on the web site to find; yes I could have guessed, but really, something like this should be documented in an obvious way). And at least one example (again, on the site) declared the DOMDocument as:

DOMDocument dom = ...pointer referece...;

Which, of course, must be:

DOMDocument *dom = ...etc.

Further, I noticed some examples (on the web site at least) made reference to XMLException, without including the appropriate header file.

I did not find documentation on the library name for linking (yes, I know: ls -la /usr/local/lib/libx*). However, little technical details like that should be documented somewhere.

Thanks for writing Xerces, folks. Now that I've got something to compile (attached), it should be a lot more fun. ;-) Please feel free to modify and display the full version of something that will compile on the web site. It would also be nice to see how to compile the application (for Linux systems using GNU C++, anyway):

        g++ -lxerces-c test.cpp

Sincerely,
Dave Jarvis
#include <xercesc/dom/DOM.hpp>
#include <xercesc/dom/DOMImplementation.hpp>
#include <xercesc/dom/DOMImplementationLS.hpp>
#include <xercesc/util/XMLException.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>

#include <xercesc/dom/DOMWriter.hpp>

#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/util/XMLUni.hpp>

#include <stdio.h>
#include <stdlib.h>

using namespace xercesc;

bool init( void )
{
  try
  {
    XMLPlatformUtils::Initialize();
  }
  catch( const XMLException &ex )
  {
    printf( "Error!\n" );
    return false;
  }

  return true;
}

int main( int argc, char *argv[] )
{
  if( init() == false )
    return 1;

  char *file = "jabber.xml";

  XMLCh t[ 100 ];
  XMLString::transcode( "LS", t, 99 );
  DOMImplementation *dom = DOMImplementationRegistry::getDOMImplementation( t );
  DOMBuilder *parser = ((DOMImplementationLS *)dom)->createDOMBuilder(
    DOMImplementationLS::MODE_SYNCHRONOUS, 0 );

  try
  {
    DOMDocument *doc = parser->parseURI( file );
  }
  catch( const XMLException &ex )
  {
    printf( "Error!\n" );
  }
  catch( const DOMException &ex )
  {
    printf( "Error!\n" );
  }
  catch( ... )
  {
    return -1;
  }

  parser->release();

  printf( "Done!\n" );

  return 0;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to