本文整理汇总了C++中SAX2XMLReader::parseNext方法的典型用法代码示例。如果您正苦于以下问题:C++ SAX2XMLReader::parseNext方法的具体用法?C++ SAX2XMLReader::parseNext怎么用?C++ SAX2XMLReader::parseNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SAX2XMLReader
的用法示例。
在下文中一共展示了SAX2XMLReader::parseNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
const char* encodingName = "UTF-8";
//SAX2XMLReader::ValSchemes valScheme = SAX2XMLReader::Val_Auto;
SAX2XMLReader::ValSchemes valScheme = SAX2XMLReader::Val_Always;
bool expandNamespaces = false;
bool doNamespaces = true;
bool doSchema = true;
bool schemaFullChecking = true;
bool namespacePrefixes = false;
SAX2XMLReader* parser = 0;
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
cout << " Error during XML initialization :\n"
<< StrX(toCatch.getMessage()) << endl;
}
parser = XMLReaderFactory::createXMLReader();
if (valScheme == SAX2XMLReader::Val_Auto)
{
parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
parser->setFeature(XMLUni::fgXercesDynamic, true);
}
if (valScheme == SAX2XMLReader::Val_Never)
{
parser->setFeature(XMLUni::fgSAX2CoreValidation, false);
}
if (valScheme == SAX2XMLReader::Val_Always)
{
parser->setFeature(XMLUni::fgSAX2CoreValidation, true);
parser->setFeature(XMLUni::fgXercesDynamic, false);
}
parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, doNamespaces);
parser->setFeature(XMLUni::fgXercesSchema, doSchema);
parser->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking);
parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, namespacePrefixes);
int errorCount = 0;
XMLPScanToken token;
try
{
TestHandler handler;
parser->setContentHandler(&handler);
parser->setErrorHandler(&handler);
if ( !parser->parseFirst(argv[1],token) )
{
cout << "parseFirst() failed" << endl;
XMLPlatformUtils::Terminate();
exit(1);
}
cout << "parseFirst() completed" << endl;
bool gotMore = true;
bool done = false;
while ( gotMore && !done )
{
gotMore = parser->parseNext(token);
if ( !gotMore )
cout << "parseNext() returned 0" << endl;
cout << "buffer = " << handler.buffer << endl;
if ( handler.buffer.size() > 32 )
handler.buffer = "";
}
errorCount = parser->getErrorCount();
cout << handler.buffer << endl;
}
catch (const XMLException& toCatch)
{
cout << "\nAn error occurred\n Error: "
<< StrX(toCatch.getMessage())
<< "\n" << endl;
XMLPlatformUtils::Terminate();
delete parser;
throw;
}
catch (const SAXParseException& e)
{
cout << "\na SAXParseException occurred in file "
<< StrX(e.getSystemId())
<< ", line " << e.getLineNumber()
<< ", char " << e.getColumnNumber()
<< "\n Message: " << StrX(e.getMessage()) << endl;
XMLPlatformUtils::Terminate();
delete parser;
throw;
//.........这里部分代码省略.........