当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::RemoveChild方法代码示例

本文整理汇总了C++中TiXmlElement::RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::RemoveChild方法的具体用法?C++ TiXmlElement::RemoveChild怎么用?C++ TiXmlElement::RemoveChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::RemoveChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeConfigXML

bool ProRataConfig::writeConfigXML( string sOutputFile, int iTabDepth, bool bSicExtract, bool bPeptideQuan, bool bProteinQuan )
{
	FILE * pFILE;
	if( ( pFILE = fopen( sOutputFile.c_str(), "a" ) ) == NULL  ) 
	{
		cout << "ERROR: cannot write Config XML to the file: " << sOutputFile << endl;
		return false;
	}

//	TiXmlElement * pElementConfig = new TiXmlElement( "CONFIG" );
//	pElementConfig->SetAttribute( "version", getProRataVersion() );
	TiXmlDocument txdConfigFile;

	// Try loading the file.
	if ( ! ( txdConfigFile.LoadFile( sFilename.c_str() ) ) )
	{
		cout << "ERROR: Loading Configuration file!" << endl;
		return false;
	}

	TiXmlElement * pElementConfig = txdConfigFile.FirstChildElement( "CONFIG" );

	if( !pElementConfig )
	{
		cout <<  "ERROR: cannot find the CONFIG element in the given Configuration file! " << endl;
		return false;
	}
	
	TiXmlNode * pElementSIC = pElementConfig->FirstChild( "SIC_EXTRACTION" );
	TiXmlNode * pElementPeptideQuan = pElementConfig->FirstChild( "PEPTIDE_QUANTIFICATION" );
       	TiXmlNode * pElementProteinQuan = pElementConfig->FirstChild( "PROTEIN_QUANTIFICATION" );

	
	if( (!bSicExtract) && pElementSIC )
	{
		pElementConfig->RemoveChild(pElementSIC);
	}
	
	if( (!bPeptideQuan) && pElementPeptideQuan )
	{
		pElementConfig->RemoveChild(pElementPeptideQuan);
	}

	if( (!bProteinQuan) && pElementProteinQuan )
	{
		pElementConfig->RemoveChild(pElementProteinQuan);
	}
	
	pElementConfig->Print( pFILE, iTabDepth );
	fputs( "\n", pFILE );

	fclose( pFILE );
	return true;
}
开发者ID:chongle,项目名称:prorata,代码行数:54,代码来源:proRataConfig.cpp

示例2: SaveFilters

void CFilterDialog::SaveFilters()
{
	CInterProcessMutex mutex(MUTEX_FILTERS);

	CXmlFile xml(wxGetApp().GetSettingsFile(_T("filters")));
	TiXmlElement* pDocument = xml.Load();
	if (!pDocument) {
		wxString msg = xml.GetError() + _T("\n\n") + _("Any changes made to the filters could not be saved.");
		wxMessageBoxEx(msg, _("Error loading xml file"), wxICON_ERROR);

		return;
	}

	TiXmlElement *pFilters = pDocument->FirstChildElement("Filters");
	while (pFilters) {
		pDocument->RemoveChild(pFilters);
		pFilters = pDocument->FirstChildElement("Filters");
	}

	pFilters = pDocument->LinkEndChild(new TiXmlElement("Filters"))->ToElement();

	for (auto const& filter : m_globalFilters) {
		TiXmlElement* pElement = new TiXmlElement("Filter");
		SaveFilter(pElement, filter);
		pFilters->LinkEndChild(pElement);
	}

	TiXmlElement *pSets = pDocument->FirstChildElement("Sets");
	while (pSets) {
		pDocument->RemoveChild(pSets);
		pSets = pDocument->FirstChildElement("Sets");
	}

	pSets = pDocument->LinkEndChild(new TiXmlElement("Sets"))->ToElement();
	SetTextAttribute(pSets, "Current", wxString::Format(_T("%d"), m_currentFilterSet));

	for (auto const& set : m_globalFilterSets) {
		TiXmlElement* pSet = pSets->LinkEndChild(new TiXmlElement("Set"))->ToElement();

		if (!set.name.empty()) {
			AddTextElement(pSet, "Name", set.name);
		}

		for (unsigned int i = 0; i < set.local.size(); ++i) {
			TiXmlElement* pItem = pSet->LinkEndChild(new TiXmlElement("Item"))->ToElement();
			AddTextElement(pItem, "Local", set.local[i] ? _T("1") : _T("0"));
			AddTextElement(pItem, "Remote", set.remote[i] ? _T("1") : _T("0"));
		}
	}

	xml.Save(true);

	m_filters_disabled = false;
}
开发者ID:juaristi,项目名称:filezilla,代码行数:54,代码来源:filter.cpp

示例3: saveProxyLastState

bool CRedisProxyCfg::saveProxyLastState(RedisProxy* proxy) {
    TiXmlElement* pRootNode = (TiXmlElement*)m_operateXmlPointer->get_rootElement();
    string nodeHash = "hash_mapping";
    TiXmlElement* pOldHashMap;
    if (GetNodePointerByName(pRootNode, nodeHash, pOldHashMap)) {
        pRootNode->RemoveChild(pOldHashMap);
    }
    TiXmlElement hashMappingNode("hash_mapping");
    for (int i = 0; i < proxy->slotCount(); ++i) {
        TiXmlElement hashNode("hash");
        hashNode.SetAttribute("value", i);
        hashNode.SetAttribute("group_name", proxy->groupBySlot(i)->groupName());
        hashMappingNode.InsertEndChild(hashNode);
    }
    pRootNode->InsertEndChild(hashMappingNode);

    // key mapping
    string nodeKey = "key_mapping";
    TiXmlElement* pKey;
    if (GetNodePointerByName(pRootNode, nodeKey, pKey)) {
        pRootNode->RemoveChild(pKey);
    }
    TiXmlElement keyMappingNode("key_mapping");

    StringMap<RedisServantGroup*>& keyMapping = proxy->keyMapping();
    StringMap<RedisServantGroup*>::iterator it = keyMapping.begin();
    for (; it != keyMapping.end(); ++it) {
        String key = it->first;
        TiXmlElement keyNode("key");
        keyNode.SetAttribute("key_name", key.data());
        RedisServantGroup* group = it->second;
        if (group != NULL) {
            keyNode.SetAttribute("group_name", group->groupName());
        }
        keyMappingNode.InsertEndChild(keyNode);
    }
    pRootNode->InsertEndChild(keyMappingNode);

    // add time
    time_t now = time(NULL);
    char fileName[512];
    struct tm* current_time = localtime(&now);
    sprintf(fileName,"onecache%d%02d%02d%02d.xml",
        current_time->tm_year + 1900,
        current_time->tm_mon + 1,
        current_time->tm_mday,
        current_time->tm_hour);

    bool ok = m_operateXmlPointer->m_docPointer->SaveFile(fileName);
    return ok;
}
开发者ID:SimpleDays,项目名称:onecache,代码行数:51,代码来源:redis-proxy-config.cpp

示例4: ApplyDeleteObjectToXml

void CAdvancedAnnotator::ApplyDeleteObjectToXml(const int knIdx)
{
	const int knFrame = m_nCurrFrame;

	TiXmlElement* elemFrame = m_pXMLFrameInfo->FirstChildElement("Frame");

	int nFrameTemp = -1;
	for(elemFrame; elemFrame; elemFrame = elemFrame->NextSiblingElement())
	{
		elemFrame->Attribute("Number",&nFrameTemp);
		if(nFrameTemp == knFrame)
			break;
	}

	if(nFrameTemp == knFrame)
	{
		TiXmlElement* elemObject = elemFrame->FirstChildElement("Object");
		for (elemObject; elemObject; elemObject = elemObject->NextSiblingElement())
		{
			int nIdTemp = -1;
			elemObject->Attribute("Id",&nIdTemp);
			if(nIdTemp == m_mapGT[m_nCurrFrame][knIdx].Id)
				break;
		}

		elemFrame->RemoveChild(elemObject);
		elemObject = elemFrame->FirstChildElement("Object");
		if(!elemObject)
			m_pXMLFrameInfo->RemoveChild(elemFrame);
	}
	m_mapGT[m_nCurrFrame].erase(m_mapGT[m_nCurrFrame].begin() + knIdx);
}
开发者ID:blastak,项目名称:avat,代码行数:32,代码来源:AdvancedAnnotator.cpp

示例5: xml_DelNode

/*!
*  /brief 删除指定节点的值。
*
*  /param XmlFile xml文件全路径。
*  /param strNodeName 指定的节点名。
*  /return 是否成功。true为成功,false表示失败。
*/
bool xml_DelNode(TiXmlDocument *pDoc, std::string strNodeName)
{
    TiXmlElement *pRootEle = pDoc->RootElement();

    if (NULL == pRootEle) {
        return false;
    }
    TiXmlElement *pNode = NULL;
    xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
    // 假如是根节点
    if (pRootEle == pNode) {
        if (pDoc->RemoveChild(pRootEle)) {
            return true;
        } else
            return false;
    }
    // 假如是其它节点
    if (NULL != pNode) {
        TiXmlNode *pParNode = pNode->Parent();
        if (NULL == pParNode) {
            return false;
        }

        TiXmlElement* pParentEle = pParNode->ToElement();
        if (NULL != pParentEle) {
            if (pParentEle->RemoveChild(pNode))
                return true;
            else
                return false;
        }
    } else {
        return false;
    }
    return false;
}
开发者ID:ubuntu-chu,项目名称:commu_manager,代码行数:42,代码来源:parse.cpp

示例6: DeleteXmlFile

bool DeleteXmlFile(string& szFileName, int& m_ID, sockaddr_in& m_sockaddr)
{
	string m_ip = inet_ntoa(m_sockaddr.sin_addr);
	string m_id = itos(m_ID);
	string m_port = itos(ntohs(m_sockaddr.sin_port));

	CString appPath = GetAppPath();
	string seperator = "\\";
	string fullPath = appPath.GetBuffer(0) +seperator+szFileName;

	TiXmlDocument	*myDocument = new TiXmlDocument(fullPath.c_str());
	myDocument->LoadFile();
	TiXmlElement *RootElement = myDocument->RootElement();

	TiXmlElement* pNode  = NULL;
	for(pNode = RootElement->FirstChildElement(); pNode; pNode = pNode->NextSiblingElement()){
		if(!strcmp(pNode->Value(), "Server") && !strcmp(pNode->Attribute("ID"), m_id.c_str())){
			cout<<pNode->Value()<<pNode->Attribute("ID")<<endl;
			RootElement->RemoveChild(pNode);
			break;
		}
	}
	myDocument->SaveFile(fullPath.c_str());//保存到文件
	return true;
}
开发者ID:yxd123,项目名称:SimBalance,代码行数:25,代码来源:config.cpp

示例7: TiXmlElement

int XML4NLP::SetSentencesToParagraph(const vector<string> &vecSentence, int paragraphIdx) {
  if (0 != CheckRange(paragraphIdx)) {
    return -1;
  }

  if (!document.paragraphs[paragraphIdx].sentences.empty()) {
    return -1;
  }

  Paragraph & paragraph     = document.paragraphs[paragraphIdx];
  TiXmlElement * paragraphPtr   = paragraph.paragraphPtr;
  vector<Sentence> &sentences   = paragraph.sentences;

  TiXmlText *textPtr = paragraphPtr->FirstChild()->ToText();
  if (textPtr == NULL) {
    return -1;
  } else {
    paragraphPtr->RemoveChild(textPtr);
  }

  for (int i = 0; i < vecSentence.size(); ++i) {
    TiXmlElement *sentencePtr = new TiXmlElement(TAG_SENT);
    sentencePtr->SetAttribute(TAG_ID, static_cast<int>(i));
    sentencePtr->SetAttribute(TAG_CONT, vecSentence[i].c_str());
    paragraphPtr->LinkEndChild(sentencePtr);

    sentences.push_back( Sentence() );
    sentences[sentences.size()-1].sentencePtr = sentencePtr;
  }

  return 0;
}
开发者ID:HIT-SCIR,项目名称:ltp,代码行数:32,代码来源:Xml4nlp.cpp

示例8: Write

void ConfigManager::Write(const wxString& name, const ConfigManagerContainer::IntToStringMap& map)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlElement *leaf = GetUniqElement(e, key);

    TiXmlElement *mNode;
    mNode = GetUniqElement(leaf, _T("ismap"));
    leaf->RemoveChild(mNode);
    mNode = GetUniqElement(leaf, _T("ismap"));

    wxString tmp;
    for (ConfigManagerContainer::IntToStringMap::const_iterator it = map.begin(); it != map.end(); ++it)
    {
        tmp.Printf(_T("x%d"), (int) it->first);
        TiXmlElement s(tmp.mb_str());

        TiXmlText t(cbU2C(it->second));
        t.SetCDATA(true);

        s.InsertEndChild(t);
        mNode->InsertEndChild(s);
    }
}
开发者ID:alpha0010,项目名称:codeblocks_sf,代码行数:25,代码来源:configmanager.cpp

示例9: DeleteNodeByNameIndex

/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:删除XML文件中指定的节点的最后一个节点
 * 参数说明:
 * delNodeName:需要删除的节点的名称
 *   nodeIndex:需要删除的节点的位置
 * 注意事项:null
 * 修改日期:2015/12/12 16:49:00
 ***********************************************************************************************************/
bool OperationProfile_XML::DeleteNodeByNameIndex(char* delNodeName, int nodeIndex)
{
	if (nodeIndex >= groupNodeCount)
		printf("当前删除的节点位置不存在!");

	if (!OperationProfile_XML::XMLExits())
		return false;

	TiXmlDocument* myDocument = new TiXmlDocument();

	if (NULL == myDocument)
		return false;
	myDocument->LoadFile(IOperationProfile::ProfileAddress);

	TiXmlElement* pRootEle = myDocument->RootElement();
	if (NULL == pRootEle)
		return false;

	TiXmlElement *pNode = NULL;

	if (arrayIndex != 0)
		arrayIndex = 0;
	if (!GetNodePointerByName(pRootEle, delNodeName, pNode, nodeIndex))
		return false;

	if (pRootEle == pNode)
	{
		if (myDocument->RemoveChild(pRootEle))
		{
			myDocument->SaveFile(IOperationProfile::ProfileAddress);
			return true;
		}
		else
		{
			return false;
		}
	}

	if (NULL != pNode)
	{
		TiXmlNode* pParNode = pNode->Parent();
		if (NULL == pParNode)
			return false;

		TiXmlElement* pParentEle = pParNode->ToElement();
		if (NULL != pParentEle)
		{
			if (pParentEle->RemoveChild(pNode))
				myDocument->SaveFile(IOperationProfile::ProfileAddress);
			else
				return false;
		}
	}
	else
	{
		return false;
	}
	return false;
}
开发者ID:zhjjssyf20120925,项目名称:OperationProfile,代码行数:68,代码来源:OperationProfile_XML.cpp

示例10: ClearBookmarks

bool CSiteManager::ClearBookmarks(wxString sitePath)
{
	if (sitePath[0] != '0')
		return false;

	sitePath = sitePath.Mid(1);

	// We have to synchronize access to sitemanager.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_SITEMANAGER);

	CXmlFile file;
	TiXmlElement* pDocument = file.Load(_T("sitemanager"));

	if (!pDocument)
	{
		wxString msg = file.GetError() + _T("\n") + _("The bookmarks could not be cleared.");
		wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);

		return false;
	}

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
		return false;

	std::list<wxString> segments;
	if (!UnescapeSitePath(sitePath, segments))
	{
		wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pChild = GetElementByPath(pElement, segments);
	if (!pChild || strcmp(pChild->Value(), "Server"))
	{
		wxMessageBox(_("Site does not exist."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement *pBookmark = pChild->FirstChildElement("Bookmark");
	while (pBookmark)
	{
		pChild->RemoveChild(pBookmark);
		pBookmark = pChild->FirstChildElement("Bookmark");
	}

	wxString error;
	if (!file.Save(&error))
	{
		if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2)
			return true;

		wxString msg = wxString::Format(_("Could not write \"%s\", the selected sites could not be exported: %s"), file.GetFileName().GetFullPath().c_str(), error.c_str());
		wxMessageBox(msg, _("Error writing xml file"), wxICON_ERROR);
	}

	return true;
}
开发者ID:pappacurds,项目名称:filezilla,代码行数:59,代码来源:sitemanager.cpp

示例11: UnSet

void ConfigManager::UnSet(const wxString& name)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlNode *leaf = GetUniqElement(e, key);
    e->RemoveChild(leaf);
}
开发者ID:alpha0010,项目名称:codeblocks_sf,代码行数:8,代码来源:configmanager.cpp

示例12: run

void SuppThread::run()
{
    QString pathfile = QDir::home().path()+"/AppData/Roaming/FileZilla/sitemanager.xml";

     // convert QString to const char
     TiXmlDocument doc(pathfile.toStdString().c_str());

     if(!doc.LoadFile())
     {
         emit isErrorXml(0);
         return;
     }

     TiXmlHandle hdl(&doc);

     // Go to the "Server" Node
     TiXmlElement *elem = hdl.FirstChildElement().FirstChildElement().FirstChildElement().Element();
     TiXmlElement *rootServer = hdl.FirstChildElement().FirstChildElement().Element();

     if(!elem){
         emit isErrorXml(1);
         return;
     }

     // Parse all "Server" Node to find the node witch will be delete
     bool find = false;
     bool isDelete = false;
     while ( elem )
     {
         if ( QString(elem->FirstChildElement("Name")->GetText()) == node )
            find = true;

         if ( QString(elem->FirstChildElement("Comments")->GetText()).isEmpty() )
             elem->FirstChildElement("Comments")->LinkEndChild(new TiXmlText(""));

         if ( QString(elem->FirstChildElement("LocalDir")->GetText()).isEmpty() )
             elem->FirstChildElement("LocalDir")->LinkEndChild(new TiXmlText(""));

         if ( QString(elem->FirstChildElement("RemoteDir")->GetText()).isEmpty() )
             elem->FirstChildElement("RemoteDir")->LinkEndChild(new TiXmlText(""));

         if ( find )
         {
             if ( rootServer->RemoveChild(elem) )
                 isDelete = true;

             emit NodeDelete(isDelete);
             doc.SaveFile();
             break;
         }

         elem = elem->NextSiblingElement();
     }

     qDebug()<<"Thread delete is Out"<<endl;

    return;
}
开发者ID:Johann-S,项目名称:FileZilla-Password-Manager,代码行数:58,代码来源:suppthread.cpp

示例13: removeElement

bool xmlManager::removeElement(std::string parent, std::string child)
{
    TiXmlElement * node = getNode(parent);
    TiXmlElement * childNode = getNode(child);

    if (node == NULL || childNode == NULL)
        return false;
    
    return node->RemoveChild(childNode);
}
开发者ID:simonesalvo,项目名称:baggre,代码行数:10,代码来源:xmlManager.cpp

示例14: DeleteNodeByNameAll

/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:删除XML文件中所有符合条件的节点
 * 参数说明:
 * strNodeName:需要删除的节点指针的名称
 * 注意事项:null
 * 修改日期:2015/12/13 14:52:00
 ***********************************************************************************************************/
bool OperationProfile_XML::DeleteNodeByNameAll(char* delNodeName)
{
	if (!OperationProfile_XML::XMLExits())
		return false;

	TiXmlDocument* myDocument = new TiXmlDocument();

	if (NULL == myDocument)
		return false;
	myDocument->LoadFile(IOperationProfile::ProfileAddress);

	TiXmlElement* pRootEle = myDocument->RootElement();
	if (NULL == pRootEle)
		return false;

	if (arrayIndex != 0)
		arrayIndex = 0;
	TiXmlElement* pNodes[] = { NULL, NULL };																		// 该处设计存在缺陷,无法定义动态数组
	GetNodePointerByNameAll(pRootEle, delNodeName, pNodes);


	if (pRootEle == pNodes[0])
	{
		if (myDocument->RemoveChild(pRootEle))
		{
			myDocument->SaveFile(IOperationProfile::ProfileAddress);
			return true;
		}
		else
		{
			return false;
		}
	}

	if (NULL != pNodes)
	{
		for (int i = 0; i < groupNodeCount; i++)
		{
			TiXmlNode* pParNode = pNodes[i]->Parent();
			if (NULL == pParNode)
				return false;

			TiXmlElement* pParentEle = pParNode->ToElement();
			if (NULL != pParentEle)
				if (pParentEle->RemoveChild(pNodes[i]))
					myDocument->SaveFile(IOperationProfile::ProfileAddress);
		}
	}
	else
	{
		return false;
	}
	return false;
}
开发者ID:zhjjssyf20120925,项目名称:OperationProfile,代码行数:62,代码来源:OperationProfile_XML.cpp

示例15: mutex

const std::list<CServer> CRecentServerList::GetMostRecentServers(bool lockMutex /*=true*/)
{
	CInterProcessMutex mutex(MUTEX_MOSTRECENTSERVERS, false);
	if (lockMutex)
		mutex.Lock();

	if (!m_XmlFile.HasFileName() || m_XmlFile.Modified())
		m_XmlFile.Load(_T("recentservers"));
	else
		return m_mostRecentServers;

	TiXmlElement* pElement = m_XmlFile.GetElement();
	if (!pElement || !(pElement = pElement->FirstChildElement("RecentServers")))
		return m_mostRecentServers;

	m_mostRecentServers.clear();
    
	bool modified = false;
	TiXmlElement* pServer = pElement->FirstChildElement("Server");
	while (pServer)
	{
		CServer server;
		if (!GetServer(pServer, server) || m_mostRecentServers.size() >= 10)
		{
			TiXmlElement* pRemove = pServer;
			pServer = pServer->NextSiblingElement("Server");
			pElement->RemoveChild(pRemove);
			modified = true;
		}
		else
		{
			std::list<CServer>::const_iterator iter;
			for (iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); iter++)
			{
				if (*iter == server)
					break;
			}
			if (iter == m_mostRecentServers.end())
				m_mostRecentServers.push_back(server);
			pServer = pServer->NextSiblingElement("Server");
		}
	}

	if (modified)
	{
		wxString error;
		m_XmlFile.Save(&error);
	}

	return m_mostRecentServers;
}
开发者ID:idgaf,项目名称:FileZilla3,代码行数:51,代码来源:recentserverlist.cpp


注:本文中的TiXmlElement::RemoveChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。