High Performance XML Parsing in C++
Vol. 1 Issue 5, p43
Listing 1

acmepcxml::XMLImporter importer;

// Call the acmepcxml::Initialize() function to register the create functions
// for the acmepcxml classes
acmepcxml::Initialize();

try {
importer.ImportFromFile(sInputFileName, fPreprocess);
}
catch (eXactML::XException & e)
{
std::cerr << e.GetMsg() << std::endl;
 std::cerr << "in " << e.GetSourceFile() << " at line number " <<
e.GetSourceLine() << std::endl;
 return 1;
}

cout << "Read in XML file with no errors." << std::endl;

acmepc *acmepc = dynamic_cast<acmepcxml::acmepc *> (importer.GetXObject());

cout << "Successfully cast XML importer root to acmepcxml::acmepc" << std::endl;

// validate the data in the classes, throws an exception if bad.
try {
 acmepc->IsValid();
}
catch (eXactML::XException & e) {
 cout << "Exception in validating XML" << std::endl;
 cout << e.GetMsg() << std::endl;
 eXactML::XMLImporterBase::DeleteImportedXObject(acmepc);
 return 1;
}

cout << "Validated acmepcxml::acmepc object" << std::endl;

// generate the XML
try {
acmepc->EmitXML(cout);
}
catch (eXactML::XException e) {
 cout << "Exception in generating XML" << std::endl;
 cout << e.GetMsg() << std::endl;
 eXactML::XMLImporterBase::DeleteImportedXObject(acmepc);
 return 1;
}

cout << "Emitted XML to file worked fine." << std::endl;
eXactML::XMLImporterBase::DeleteImportedXObject(acmepc);
return 0;