本文整理汇总了C++中TiXmlElement::ReplaceChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::ReplaceChild方法的具体用法?C++ TiXmlElement::ReplaceChild怎么用?C++ TiXmlElement::ReplaceChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::ReplaceChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PutBoolean
void XMLDocument::PutBoolean(TiXmlElement& parent, const string& szName, bool bValue)
{
TiXmlElement newelement(szName.c_str());
TiXmlText text(bValue? "true" : "false");
newelement.InsertEndChild(text);
TiXmlElement* existing = parent.FirstChildElement(szName.c_str());
if(existing)
parent.ReplaceChild(existing, newelement);
else
parent.InsertEndChild(newelement);
}
示例2: PutString
void XMLDocument::PutString(TiXmlElement& parent, const string& szName, const string& szValue)
{
TiXmlElement newelement(szName.c_str());
TiXmlText text(szValue.c_str());
newelement.InsertEndChild(text);
TiXmlElement* existing = parent.FirstChildElement(szName.c_str());
if(existing)
parent.ReplaceChild(existing, newelement);
else
parent.InsertEndChild(newelement);
}
示例3: SetSimpleExtension
void GpxTrkElement::SetSimpleExtension(const wxString &name, const wxString &value)
{
//FIXME: if the extensions don't exist, we should create them
TiXmlElement * exts = FirstChildElement("extensions");
if (exts) {
TiXmlElement * ext = exts->FirstChildElement(name.ToUTF8());
if (ext)
exts->ReplaceChild(ext, GpxSimpleElement(name, value));
else
exts->LinkEndChild(new GpxSimpleElement(name, value));
}
}
示例4: TiXmlDocument
// get the configuration file using hobbit protocol config
void AgentBBWinUpdate::RunUpdate(std::string & configFile) {
TiXmlDocument * update, * toUpdate;
DeleteFile(m_bbwinupdateTmpFilePath.c_str());
m_mgr.Config(configFile.c_str(), m_bbwinupdateTmpFilePath.c_str());
update = new TiXmlDocument(m_bbwinupdateTmpFilePath.c_str());
bool loadUpdateOkay = update->LoadFile();
if ( !loadUpdateOkay ) {
string err = (string)" failed to get the update " + configFile + (string)" or the update file is not correct";
m_mgr.ReportEventError(err.c_str());
}
toUpdate = new TiXmlDocument(m_bbwinCfgTmpPath.c_str());
bool loadToUpdateOkay = toUpdate->LoadFile();
if ( !loadToUpdateOkay ) {
delete update;
string err = (string)" failed to open " + m_bbwinCfgTmpPath;
m_mgr.ReportEventError(err.c_str());
}
TiXmlElement *root = update->FirstChildElement( "configuration" );
TiXmlElement *toUpdateRoot = toUpdate->FirstChildElement( "configuration" );
if ( root && toUpdateRoot) {
for (TiXmlNode * nameSpaceNode = root->FirstChild(); nameSpaceNode != NULL; nameSpaceNode = root->IterateChildren(nameSpaceNode)) {
// we never update bbwin namespace (too dangerous)
if (strcmp(nameSpaceNode->Value(), "bbwin") != 0) {
TiXmlNode * destNameSpaceNode = toUpdateRoot->FirstChild(nameSpaceNode->Value());
if ( destNameSpaceNode ) {
toUpdateRoot->ReplaceChild(destNameSpaceNode, *nameSpaceNode);
} else {
toUpdateRoot->InsertEndChild(*nameSpaceNode);
}
} else {
string err = (string)" bbwin namespace update is not permitted. Please check the " + (string)configFile + (string)" on your hobbit server.";
m_mgr.ReportEventError(err.c_str());
}
}
}
if (toUpdate->SaveFile() != true) {
string err = (string)" failed to save " + m_bbwinCfgTmpPath;
m_mgr.ReportEventError(err.c_str());
}
delete update;
delete toUpdate;
}