本文整理汇总了C++中XMLDocument::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument::Accept方法的具体用法?C++ XMLDocument::Accept怎么用?C++ XMLDocument::Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDocument
的用法示例。
在下文中一共展示了XMLDocument::Accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getXMLNivel
std::string Partida::getXMLNivel() {
XMLDocument doc;
bool cargoArchivo = doc.LoadFile(idNiveles[contadorNiveles]);
if (cargoArchivo == false) {
std::cout << "\tError al abrir el archivo XML." << std::endl;
return std::string();
}
TiXmlPrinter printer;
printer.SetIndent("");
printer.SetLineBreak("");
doc.Accept(&printer);
return printer.CStr();
}
示例2: parse
void CCAndroidStringsParser::parse(const string& path, const CCDictionary& dict) {
// map file path
string localPath = CCUtils::mapLocalPath(path);
// load file, if success, visit it
XMLDocument* doc = new XMLDocument();
if(doc->LoadFile(localPath.c_str()) == XML_NO_ERROR) {
m_dict = (CCDictionary*)&dict;
doc->Accept(this);
}
// release
delete doc;
}
示例3: writeToFile
void CSettings::writeToFile() {
XMLDocument doc;
XMLElement *pSettingsElem = doc.NewElement("settings");
doc.InsertEndChild(pSettingsElem);
// Input
XMLElement *pInput = doc.NewElement("input");
pSettingsElem->InsertEndChild(pInput);
pInput->SetAttribute("map_editor_button_size",
m_InputSettings.m_fMapEditorButtonSize);
XMLElement *pInputTouch = doc.NewElement("touch");
pInput->InsertEndChild(pInputTouch);
pInputTouch->SetAttribute("button_size", m_InputSettings.m_fTouchButtonSize);
// video
XMLElement *pVideo = doc.NewElement("video");
pSettingsElem->InsertEndChild(pVideo);
pVideo->SetAttribute("hud_size", m_VideoSettings.m_fHUDSize);
// social gaming
XMLElement *pSocialGaming = doc.NewElement("social_gaming");
pSettingsElem->InsertEndChild(pSocialGaming);
pSocialGaming->SetAttribute("login_on_start", m_SocialGamingSettings.m_bLoginOnStart ? "true" : "false");
// do the output
XMLPrinter xmlprinter;
doc.Accept(&xmlprinter);
std::string header("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
std::string text(xmlprinter.CStr());
std::fstream stream;
if (CFileManager::openFile(stream, SETTINGS_FILE_PATH, std::ofstream::out | std::ofstream::trunc)) {
stream << header;
stream << text;
stream.close();
}
}
示例4: 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;" );