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


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

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


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

示例1: DeleteNode

	void DirectoryWriter::DeleteNode(char *nodeName)
	{
		TiXmlDocument doc("Config.xml");
		bool loadOkay = doc.LoadFile();

		if (!loadOkay)
		{
			printf("Could not load test file 'Config.xml'. Error='%s'. Exiting.\n", doc.ErrorDesc());
			exit(1);
		}

		TiXmlNode *versionNode = 0;
		versionNode = doc.FirstChild("Version");
		TiXmlElement *versionelement = versionNode->ToElement();
		std::string version = versionelement->Attribute("Number");
		int value = atoi(version.c_str());
		value += 1;
		versionelement->SetAttribute("Number", value);

		TiXmlNode *node = 0;
		node = doc.FirstChild("Filesystem");
		TiXmlElement *searchNode = 0;

		for (TiXmlElement* e = node->FirstChildElement("File"); e != NULL; e = e->NextSiblingElement("File"))
		{
			const char *attribute = e->Attribute("filename");
			if (strcmp(attribute, nodeName) == 0)
			{
				node->RemoveChild(e);
				break;
			}
		}
		doc.SaveFile();
	}
开发者ID:BioDice,项目名称:OS3CS,代码行数:34,代码来源:DirectoryWriter.cpp

示例2: read_from_configuration

void Profile::read_from_configuration (Configuration* configuration)
{
    TiXmlNode* node = 0;

    // insert initial mandatory declaration if not present
    TiXmlNode* decl = 0;
    for (TiXmlNode* child = xmlProfileDoc->FirstChild();
	 child && !decl; child = child->NextSibling() ) {
	decl = child->ToDeclaration ();
    }
    if (! decl) {
	node = xmlProfileDoc->InsertEndChild( TiXmlDeclaration( "1.0", "UTF-8", "no" ) );
	assert (node);
    }

    // for each configuration variable in configuration
    for (std::map<std::string, Variable*>::const_iterator conf_it = configuration->begin();
	 conf_it != configuration->end();
	 conf_it ++) {

	// start from root of DOM
	node = xmlProfileDoc;

	// get the variable name and break it up in its component vector
	std::string variable_name = conf_it->second->get_name ();
	std::vector<std::string> variable_name_vector = Variable::string_to_vector (variable_name);

	// for each component in variable name vector
	for (size_t i = 0; i < variable_name_vector.size(); i++) {

	    // check if component element exists
	    TiXmlElement* existing = node->FirstChildElement (variable_name_vector[i].c_str());
	    if (existing) {
		// carry on with existing component
		node = existing;

	    } else {
		// create missing component element and carry on with new component
		node = node->InsertEndChild (TiXmlElement (variable_name_vector[i].c_str()));
		assert (node);
	    }
	}

	// check if a text node for element exists
	TiXmlText* text = 0;
	for(TiXmlNode* child = node->FirstChild(); child && !text; child = child->NextSibling() ) {
	    text = child->ToText ();
	}
	if (text) {
	    // text child already exists, so remove it to set new value
	    node->RemoveChild (text);
	}
	node = node->InsertEndChild (TiXmlText (conf_it->second->get_value ().c_str ()));
	assert (node);
    
    }
}
开发者ID:allisonChilton,项目名称:Presage,代码行数:57,代码来源:profile.cpp

示例3: DoLayers

static void DoLayers()
{
/* ---- */
/* Open */
/* ---- */

	XML_TKEM		xml( gArgs.GetXML(), flog );
	TiXmlElement*	layer	= xml.GetFirstLayer();

/* ------------------------- */
/* Kill layers outside range */
/* ------------------------- */

	TiXmlNode*		lyrset = layer->Parent();
	TiXmlElement*	next;

	for( ; layer; layer = next ) {

		// next layer0 before deleting anything
		next = layer->NextSiblingElement();

		int	z = atoi( layer->Attribute( "z" ) );

		if( z < gArgs.zmin || z > gArgs.zmax )
			lyrset->RemoveChild( layer );
	}

/* --------------------------- */
/* Copies for remaining layers */
/* --------------------------- */

	layer = lyrset->FirstChild( "t2_layer" )->ToElement();

	for( ; layer; layer = layer->NextSiblingElement() ) {

		int	z = atoi( layer->Attribute( "z" ) );

		gArgs.NewLayer( z );
		UpdateTiles( layer );
	}

/* ---- */
/* Save */
/* ---- */

	xml.Save( "xmltmp.txt", true );

/* ------------------ */
/* Rename version two */
/* ------------------ */

	gArgs.RenameXML();
}
开发者ID:adisuissa,项目名称:Alignment_Projects,代码行数:53,代码来源:localProj.cpp

示例4: remove_object

void XMLConfiguration::remove_object(const string& section_name, const string& object_name)
{
	bool section_found = false;
	bool object_found = false;
	
	TiXmlNode* child = 0;
	
	TiXmlNode* nephew = 0;
	
	if(m_document->NoChildren()==false)
	{
		
		while((!section_found) && ( child = m_document->IterateChildren( child ) ))
		{
			if(string(child->Value())==section_name)
			{
				section_found = true;
			}
		}
	}
		
	if(section_found == false)
	{
		return;
	}
	
	if(child->NoChildren()==false)
	{
		
		while((!object_found) && ( nephew = child->IterateChildren( nephew ) ))
		{
			if(string(nephew->Value())==object_name)
			{
				object_found = true;
			}
		}
	}
	
	if(object_found == false)
	{
		return;
	}
	
	child->RemoveChild(nephew);
}
开发者ID:giuppe,项目名称:mdc,代码行数:45,代码来源:xml_configuration.cpp

示例5: sa

_MEMBER_FUNCTION_IMPL( XmlNode, Remove )
{
	StackHandler sa(v);
	_CHECK_SELF( TiXmlNode, XmlNode );

	TiXmlNode* pParent = self->Parent();

	if ( pParent )
	{
		pParent->RemoveChild( self );

		sa.Return( true );
		return 1;
	}

	sa.Return( false );
	return 1;
}
开发者ID:jack9267,项目名称:vcmpserver,代码行数:18,代码来源:SQXmlFuncs.cpp

示例6: RemoveElem

/**************************************************************************
* name       : RemoveElem
* description: 删除元素
* input      : NA
* output     : NA
* return     : true - 成功,false - 失败
* remark     : NA
**************************************************************************/
bool CXml::RemoveElem()
{
    if (NULL == m_pXmlNode)
    {
        return false;
    }

    TiXmlNode* pTempParentNode = NULL;
    TiXmlNode* pTempNode = NULL;

    pTempParentNode = m_pXmlNode->Parent();//lint !e838

    if ((m_pXmlNode->PreviousSibling()) && (m_pXmlNode->PreviousSibling()->ToElement()))
    {
        pTempNode = m_pXmlNode->PreviousSibling();
    }
    else if ((m_pXmlNode->NextSibling()) && (m_pXmlNode->NextSibling()->ToElement()))
    {
        pTempNode = m_pXmlNode->NextSibling();
    }
    else
    {
        pTempNode = pTempParentNode;
    }

    //判断指针是否为空
    CHECK_POINTER(pTempParentNode,false);

    if (!pTempParentNode->RemoveChild(m_pXmlNode))
    {
        return false;
    }

    m_pXmlNode = pTempNode;

    return true;
}
开发者ID:eSDK,项目名称:esdk_elte,代码行数:45,代码来源:eLTE_Xml.cpp

示例7: DeleteAllSubNodes

CXMLNodeImpl::~CXMLNodeImpl ( void )
{
    // Remove from array over XML stuff
    if ( m_bUsingIDs )
        CXMLArray::PushUniqueID ( this );

    // Delete our children
    DeleteAllSubNodes ();

    // We need a parent to delete the node
    if ( m_pParent )
    {
        // Remove from parent list
        m_pParent->RemoveFromList ( this );
    }
    else
    {
        // NULL it in the file if any
        if ( m_pFile )
        {
            m_pFile->m_pRootNode = NULL;
        }
    }

    // Need to delete the node?
    if ( m_pNode )
    {
        // Grab the parent of our node and delete it using that if any to prevent crashing.
        // Otherwize delete it directly.
        TiXmlNode* pParent = m_pNode->Parent ();
        if ( pParent )
            pParent->RemoveChild ( m_pNode );
        else
            delete m_pNode;
    }
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:36,代码来源:CXMLNodeImpl.cpp

示例8: UpdateAppStat

void CAppManager::UpdateAppStat(const std::string& AppId)
{
  CStdString fileName = _P("special://profile/apps/apps.xml");
  CStdString strValue, currAppStr;
  CStdString tmp;
  CStdString appsPath = _P("special://home/apps/");
  CAppDescriptor::AppDescriptorsMap installedAppsDesc;

  GetInstalledAppsInternal(installedAppsDesc, appsPath, "", false);

  TiXmlDocument xmlDoc;
  TiXmlElement *pRootElement = NULL;
  TiXmlNode *pTempNode = NULL;
  bool fixDoc = true;

  CLog::Log(LOGINFO, "updating %s's information in apps.xml", AppId.c_str());

  if ( xmlDoc.LoadFile( fileName) )
  {
    pRootElement = xmlDoc.RootElement();
    if (pRootElement)
    {
      strValue = pRootElement->Value();
      if ( strValue == "apps")
      {
        fixDoc = false;
      }
    }
  }

  if (fixDoc)
  {
    if (pRootElement)
    {
      xmlDoc.RemoveChild(pRootElement);
    }
    else
    {
      pTempNode = xmlDoc.FirstChild();
      if (pTempNode > 0)
        xmlDoc.RemoveChild(pTempNode);
    }

    pRootElement = new TiXmlElement( "apps" );
    pRootElement->SetAttribute("version", "1.0");
    xmlDoc.LinkEndChild(pRootElement);
  }

  TiXmlNode *pAppNode = pRootElement->FirstChild("app");
  TiXmlNode *pOpenedCntNode = NULL, *pIdNode = NULL, *pLastOpenedDateNode = NULL;

  while (pAppNode > 0)
  {
    pIdNode = pAppNode->FirstChild("id");
    if (pIdNode && pIdNode->FirstChild())
    {
      currAppStr = pIdNode->FirstChild()->Value();
      if (currAppStr == AppId)
      {
        pLastOpenedDateNode = pAppNode->FirstChild("lastopeneddate");
        pOpenedCntNode = pAppNode->FirstChild("timesopened");
        if (pOpenedCntNode && pOpenedCntNode->FirstChild())
        {

          int openedCnt = atoi (pOpenedCntNode->FirstChild()->Value());
          openedCnt++;
          tmp = BOXEE::BXUtils::IntToString(openedCnt);

          pOpenedCntNode->FirstChild()->SetValue(tmp.c_str());
          //CLog::Log(LOGDEBUG,"    Found name: %s", strName.c_str());
        }
        else
        {
          if (pOpenedCntNode)
          {
            pAppNode->RemoveChild(pOpenedCntNode);
          }
          TiXmlElement * timesOpenedElement = new TiXmlElement( "timesopened" );
          TiXmlText * timesOpenedText = new TiXmlText( "1" );
          timesOpenedElement->LinkEndChild( timesOpenedText );
          pAppNode->LinkEndChild(timesOpenedElement);
        }
        if (pLastOpenedDateNode)
        {
          pAppNode->RemoveChild(pLastOpenedDateNode);
        }

        tmp = BOXEE::BXUtils::IntToString(std::time(NULL));
        TiXmlElement * lastOpenedElement = new TiXmlElement( "lastopeneddate" );
        TiXmlText * lastOpenedText = new TiXmlText(tmp.c_str());
        lastOpenedElement->LinkEndChild( lastOpenedText );
        pAppNode->LinkEndChild(lastOpenedElement);
      }

      CLog::Log(LOGDEBUG, "deleting %s from apps map\n", currAppStr.c_str());
      installedAppsDesc.erase(currAppStr);
    }
    pAppNode = pAppNode->NextSiblingElement("app");

  }
//.........这里部分代码省略.........
开发者ID:Kr0nZ,项目名称:boxee,代码行数:101,代码来源:AppManager.cpp

示例9: SetSectionValue

int CHsMiscellany::SetSectionValue( CString lpszSection, CString lpszValue )
{

	CString strPath = "";
	TiXmlNode* pNode = NULL;

	if (lpszSection.IsEmpty())
	{// 删除所有<Section>下子节点

		strPath = "//Miscellany/Section";
		pNode = m_pConfigBase->GetNode(strPath, "", "", UserDoc);
		if (pNode && !::IsBadReadPtr(pNode, 1))
		{
			pNode->Clear(); // 删除所有子节点
			m_pConfigBase->GetXmlDocument(UserDoc)->SetModified(TRUE);
		}
		return 1;
	}
	else if (lpszValue.IsEmpty())
	{// 删除<Section>下 id=lpszSection的节点
		
		strPath = "//Miscellany/Section";
		pNode = m_pConfigBase->GetNode(strPath, "", "", UserDoc);
		if (pNode && !::IsBadReadPtr(pNode, 1))
		{
			strPath = "//Miscellany/Section/Item";
			TiXmlNode* pChildNode = m_pConfigBase->GetNode(strPath, "id", lpszSection, UserDoc);
			if (pChildNode && !::IsBadReadPtr(pChildNode, 1))
			{
				pNode->RemoveChild(pChildNode);
			}
		}
		return 1;
	}
	else
	{// 都不为空 更新节点

		strPath = "//Miscellany/Section";
		pNode = m_pConfigBase->SetNode(strPath);
		if (pNode && !::IsBadReadPtr(pNode, 1))
		{
			TiXmlNode* pChildNode = pNode->FirstChild();
			while(pChildNode)
			{
				if ( pChildNode->ToElement()->Attribute("id") == lpszSection)
				{
					m_pConfigBase->SetNodeAttrString(pChildNode, "value", lpszValue);
					return lpszValue.GetLength();
				}

				pChildNode = pChildNode->NextSibling();
			}

			TiXmlElement* pElement = new TiXmlElement("Item");
			pElement->SetAttribute("id", lpszSection);
			pElement->SetAttribute("value", lpszValue);
			pNode->LinkEndChild(pElement);
		}


		return lpszValue.GetLength();
	}

}
开发者ID:hefen1,项目名称:XCaimi,代码行数:64,代码来源:HsMiscellany.cpp


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