本文整理汇总了C++中XMLElement::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::Accept方法的具体用法?C++ XMLElement::Accept怎么用?C++ XMLElement::Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::Accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParsePages
void Book::ParsePages(BLUnZip& zipfile)
{
std::vector<char> filter(std::numeric_limits<unsigned char>::max(), 1);
for (unsigned char c : valid)
{
filter[c] = 0;
}
// spine.size(); or 7
for (unsigned int i = 0; i != spine.size(); i++)
{
TextVisitor tv;
std::string page ( zipfile.ExtractToString( manifest[spine[i]]) );
XMLDocument doc;
doc.Parse(page.c_str());
XMLElement* body = doc.FirstChildElement("html")->FirstChildElement("body");
body->Accept(&tv);
for (auto& v : tv.GetText())
{
alltext.push_back(v);
}
// clean up text, remove any random / corrupt characters
// https://github.com/dietmarkuehl/cputube/blob/master/cpu/test/replace.cpp
for (auto& text : alltext)
{/*
text.erase(std::remove_if(text.begin(), text.end(),
[&](unsigned char c)
{ return filter[c]; }
), text.end());
*/
std::replace_if(text.begin(), text.end(), [&](unsigned char c) { return filter[c]; }, '\'');
}
}
}
示例2: main
//.........这里部分代码省略.........
XMLElement* childText0 = doc.NewElement( "childText0" );
XMLElement* childText1 = doc.NewElement( "childText1" );
XMLNode* childNode0 = parent->InsertEndChild( childText0 );
XMLNode* childNode1 = parent->InsertAfterChild( childNode0, childText1 );
XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
}
{
// Entities not being written correctly.
// From Lynn Allen
const char* passages =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<passages count=\"006\" formatversion=\"20020620\">"
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
"</passages>";
XMLDocument doc;
doc.Parse( passages );
XMLElement* psg = doc.RootElement()->FirstChildElement();
const char* context = psg->Attribute( "context" );
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
XMLTest( "Entity transformation: read. ", expected, context, true );
FILE* textfile = fopen( "resources/out/textfile.txt", "w" );
if ( textfile )
{
XMLPrinter streamer( textfile );
psg->Accept( &streamer );
fclose( textfile );
}
textfile = fopen( "resources/out/textfile.txt", "r" );
TIXMLASSERT( textfile );
if ( textfile )
{
char buf[ 1024 ];
fgets( buf, 1024, textfile );
XMLTest( "Entity transformation: write. ",
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright \xC2\xA9.\"/>\n",
buf, false );
fclose( textfile );
}
}
{
// Suppress entities.
const char* passages =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<passages count=\"006\" formatversion=\"20020620\">"
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'.\">Crazy &ttk;</psg>"
"</passages>";
XMLDocument doc( false );
doc.Parse( passages );
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->Attribute( "context" ),
"Line 5 has "quotation marks" and 'apostrophe marks'." );
XMLTest( "No entity parsing.", doc.FirstChildElement()->FirstChildElement()->FirstChild()->Value(),
"Crazy &ttk;" );
示例3: main
//.........这里部分代码省略.........
XMLTest( "Test InsertAfterChild on empty node. ", ( childNode1 == parent->LastChild() ), true );
}
{
// Entities not being written correctly.
// From Lynn Allen
const char* passages =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<passages count=\"006\" formatversion=\"20020620\">"
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright ©.\"> </psg>"
"</passages>";
XMLDocument doc;
doc.Parse( passages );
XMLElement* psg = doc.RootElement()->FirstChildElement();
const char* context = psg->Attribute( "context" );
const char* expected = "Line 5 has \"quotation marks\" and 'apostrophe marks'. It also has <, >, and &, as well as a fake copyright \xC2\xA9.";
XMLTest( "Entity transformation: read. ", expected, context, true );
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
#endif
FILE* textfile = fopen( "textfile.txt", "w" );
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
if ( textfile )
{
XMLPrinter streamer( textfile );
psg->Accept( &streamer );
fclose( textfile );
}
#if defined(_MSC_VER)
#pragma warning ( push )
#pragma warning ( disable : 4996 ) // Fail to see a compelling reason why this should be deprecated.
#endif
textfile = fopen( "textfile.txt", "r" );
#if defined(_MSC_VER)
#pragma warning ( pop )
#endif
TIXMLASSERT( textfile );
if ( textfile )
{
char buf[ 1024 ];
fgets( buf, 1024, textfile );
XMLTest( "Entity transformation: write. ",
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'."
" It also has <, >, and &, as well as a fake copyright \xC2\xA9.\"/>\n",
buf, false );
}
fclose( textfile );
}
{
// Suppress entities.
const char* passages =
"<?xml version=\"1.0\" standalone=\"no\" ?>"
"<passages count=\"006\" formatversion=\"20020620\">"
"<psg context=\"Line 5 has "quotation marks" and 'apostrophe marks'.\">Crazy &ttk;</psg>"
"</passages>";
XMLDocument doc( false );