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


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

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


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

示例1: writeAccountName

//-------------------------------------------------------------------------------------	
void Config::writeAccountName(const char* name)
{
	if(!useLastAccountName_)
		return;

	TiXmlNode* rootNode = NULL;
	XmlPlus* xml = new XmlPlus(Resmgr::getSingleton().matchRes(fileName_).c_str());

	if(!xml->isGood())
	{
		ERROR_MSG(boost::format("Config::writeAccountName: load %1% is failed!\n") %
			fileName_.c_str());

		SAFE_RELEASE(xml);
		return;
	}

	rootNode = xml->getRootNode("accountName");
	if(rootNode != NULL)
	{
		rootNode->SetValue(name);
	}

	xml->getTxdoc()->SaveFile(fileName_.c_str());
	SAFE_RELEASE(xml);
}
开发者ID:jzgenius,项目名称:kbengine,代码行数:27,代码来源:config.cpp

示例2: SetText

    void GD_EXTENSION_API SetText(const std::string &refName, const std::string &text, RuntimeScene &scene)
    {
        TiXmlNode *refNode = RefManager::Get(&scene)->GetRef(refName);

        if(refNode)
        {
            refNode->SetValue(text.c_str());
        }
    }
开发者ID:4ian,项目名称:GD-Extensions,代码行数:9,代码来源:AdvancedXMLTools.cpp

示例3: writeconf

bool writeconf(int hconf,char *option,char *field,char *value )
{
    TiXmlNode       *node               = 0;
    TiXmlElement    *rootElement        = 0;
    TiXmlElement    *settingElement     = 0;
    TiXmlElement    *fieldElement       = 0;
    TiXmlElement    *newldElement       = 0;
    TiXmlDocument   *pdoc               = 0;
    TiXmlText       *pTextValue         = 0;
    TiXmlNode       *pTextNode          = 0;
    if(hconf){
        pdoc = (TiXmlDocument*)hconf;
    } else {
        return false;
    }
    node = pdoc->RootElement();
    if(!node){                              //here we need create a new node
        node = new TiXmlElement(ROOT_NAME);
        pdoc->LinkEndChild(node);    
                                            //root element no exist,the create a new element
    }
    if(strcmp(ROOT_NAME,node->Value())){
        //delete and create a new one
        return false;
    }
    rootElement     = node->ToElement(); //we come to <SNWTool>   </SNWTool> element
    settingElement  = rootElement->FirstChildElement(option);
    if( settingElement) {
        fieldElement    = settingElement->FirstChildElement(field);
        if(fieldElement){
            pTextNode       = fieldElement->FirstChild();
            if(pTextNode) {
                pTextNode->SetValue(value);
            } else {
                pTextValue  = new TiXmlText(value);
                fieldElement->LinkEndChild(pTextValue);
            }
        } else {
            pTextValue      = new TiXmlText(value);
            fieldElement    = new TiXmlElement(field);
            fieldElement->LinkEndChild(pTextValue);
            settingElement->LinkEndChild( fieldElement );
        }
    } else {
        pTextValue      = new TiXmlText(value);
        fieldElement    = new TiXmlElement(field);
        fieldElement->LinkEndChild(pTextValue);
        settingElement  = new TiXmlElement(option);
        settingElement->LinkEndChild( fieldElement );
        rootElement->LinkEndChild( settingElement );
    } 
    return true;
}
开发者ID:lidongqiang,项目名称:wvpctool,代码行数:53,代码来源:xmlib.cpp

示例4: ResolveParametersForNode

void CGUIIncludes::ResolveParametersForNode(TiXmlElement *node, const Params& params)
{
  if (!node)
    return;
  std::string newValue;
  // run through this element's attributes, resolving any parameters
  TiXmlAttribute *attribute = node->FirstAttribute();
  while (attribute)
  {
    ResolveParamsResult result = ResolveParameters(attribute->ValueStr(), newValue, params);
    if (result == SINGLE_UNDEFINED_PARAM_RESOLVED && strcmp(node->Value(), "param") == 0 &&
        strcmp(attribute->Name(), "value") == 0 && node->Parent() && strcmp(node->Parent()->Value(), "include") == 0)
    {
      // special case: passing <param name="someName" value="$PARAM[undefinedParam]" /> to the nested include
      // this usually happens when trying to forward a missing parameter from the enclosing include to the nested include
      // problem: since 'undefinedParam' is not defined, it expands to <param name="someName" value="" /> and overrides any default value set with <param name="someName" default="someValue" /> in the nested include
      // to prevent this, we'll completely remove this parameter from the nested include call so that the default value can be correctly picked up later
      node->Parent()->RemoveChild(node);
      return;
    }
    else if (result != NO_PARAMS_FOUND)
      attribute->SetValue(newValue);
    attribute = attribute->Next();
  }
  // run through this element's value and children, resolving any parameters
  TiXmlNode *child = node->FirstChild();
  if (child)
  {
    if (child->Type() == TiXmlNode::TINYXML_TEXT)
    {
      ResolveParamsResult result = ResolveParameters(child->ValueStr(), newValue, params);
      if (result == SINGLE_UNDEFINED_PARAM_RESOLVED && strcmp(node->Value(), "param") == 0 &&
          node->Parent() && strcmp(node->Parent()->Value(), "include") == 0)
      {
        // special case: passing <param name="someName">$PARAM[undefinedParam]</param> to the nested include
        // we'll remove the offending param tag same as above
        node->Parent()->RemoveChild(node);
      }
      else if (result != NO_PARAMS_FOUND)
        child->SetValue(newValue);
    }
    else if (child->Type() == TiXmlNode::TINYXML_ELEMENT)
    {
      do
      {
        TiXmlElement *next = child->NextSiblingElement();   // save next as current child might be removed from the tree
        ResolveParametersForNode(static_cast<TiXmlElement *>(child), params);
        child = next;
      }
      while (child);
    }
  }
}
开发者ID:AchimTuran,项目名称:xbmc,代码行数:53,代码来源:GUIIncludes.cpp

示例5: tixmldocument_write

  int tixmldocument_write(lua_State *L) {
    TiXmlDocument *xmldoc;
    TiXmlDocument_ud* xmldoc_userdata = (TiXmlDocument_ud *) luaL_checkudata(L, 1, "TiXmlDocument");
    xmldoc = xmldoc_userdata->xmldoc;
    const char *path = luaL_checkstring(L, 2); // path
    const char *value = luaL_checkstring(L, 3); // new value

    lua_pop(L, 3);

    char *attr_name;
    TiXmlNode *node = find_node(path, xmldoc->RootElement(), &attr_name);

    if (node) {
      if (attr_name) {
	if (node->Type() == TiXmlNode::ELEMENT) {
	  TiXmlElement *elt_node = dynamic_cast<TiXmlElement *>(node);

	  if (elt_node->Attribute(attr_name)) {
	    elt_node->SetAttribute(attr_name, value);
	    delete attr_name;
	    lua_pushboolean(L, 1);
	    return 1;
	  }
	}
	luaL_error(L, "invalid attribute: %s", attr_name);
	delete attr_name;
	return 0;
      } else {
	TiXmlNode *n = node->FirstChild();
	if (n) {
	  if (n->Type()==TiXmlNode::TEXT) {
	    n->SetValue(value);
	  } else {
	    return luaL_error(L, "%s does not point to a text node", path);
	  }
	} else {
	  // create the text child
	  TiXmlText *new_text_node = new TiXmlText(value);
	  // and add it
	  node->LinkEndChild(new_text_node);
	}
      }

      lua_pushboolean(L, 1);
      return 1;
    } else {
      return luaL_error(L, "path not found: %s", path);
    }
  }
开发者ID:theypsilon,项目名称:MOD_TinyXML,代码行数:49,代码来源:ltxml.cpp

示例6: ResolveExpressions

void CGUIIncludes::ResolveExpressions(TiXmlElement *node)
{
  if (!node)
    return;

  TiXmlNode *child = node->FirstChild();
  if (child && child->Type() == TiXmlNode::TINYXML_TEXT && m_expressionNodes.count(node->ValueStr()))
  {
    child->SetValue(ResolveExpressions(child->ValueStr()));
  }
  else
  {
    TiXmlAttribute *attribute = node->FirstAttribute();
    while (attribute)
    {
      if (m_expressionAttributes.count(attribute->Name()))
        attribute->SetValue(ResolveExpressions(attribute->ValueStr()));

      attribute = attribute->Next();
    }
  }
}
开发者ID:Razzeee,项目名称:xbmc,代码行数:22,代码来源:GUIIncludes.cpp

示例7: LoadData

bool CPlayListASX::LoadData(istream& stream)
{
  CLog::Log(LOGNOTICE, "Parsing ASX");

  if(stream.peek() == '[')
  {
    return LoadAsxIniInfo(stream);
  }
  else
  {
    CXBMCTinyXML xmlDoc;
    stream >> xmlDoc;

    if (xmlDoc.Error())
    {
      CLog::Log(LOGERROR, "Unable to parse ASX info Error: %s", xmlDoc.ErrorDesc());
      return false;
    }

    TiXmlElement *pRootElement = xmlDoc.RootElement();

    // lowercase every element
    TiXmlNode *pNode = pRootElement;
    TiXmlNode *pChild = NULL;
    CStdString value;
    value = pNode->Value();
    value.ToLower();
    pNode->SetValue(value);
    while(pNode)
    {
      pChild = pNode->IterateChildren(pChild);
      if(pChild)
      {
        if (pChild->Type() == TiXmlNode::TINYXML_ELEMENT)
        {
          value = pChild->Value();
          value.ToLower();
          pChild->SetValue(value);

          TiXmlAttribute* pAttr = pChild->ToElement()->FirstAttribute();
          while(pAttr)
          {
            value = pAttr->Name();
            value.ToLower();
            pAttr->SetName(value);
            pAttr = pAttr->Next();
          }
        }

        pNode = pChild;
        pChild = NULL;
        continue;
      }

      pChild = pNode;
      pNode = pNode->Parent();
    }
    CStdString roottitle = "";
    TiXmlElement *pElement = pRootElement->FirstChildElement();
    while (pElement)
    {
      value = pElement->Value();
      if (value == "title")
      {
        roottitle = pElement->GetText();
      }
      else if (value == "entry")
      {
        CStdString title(roottitle);

        TiXmlElement *pRef = pElement->FirstChildElement("ref");
        TiXmlElement *pTitle = pElement->FirstChildElement("title");

        if(pTitle)
          title = pTitle->GetText();

        while (pRef)
        { // multiple references may apear for one entry
          // duration may exist on this level too
          value = pRef->Attribute("href");
          if (value != "")
          {
            if(title.IsEmpty())
              title = value;

            CLog::Log(LOGINFO, "Adding element %s, %s", title.c_str(), value.c_str());
            CFileItemPtr newItem(new CFileItem(title));
            newItem->SetPath(value);
            Add(newItem);
          }
          pRef = pRef->NextSiblingElement("ref");
        }
      }
      else if (value == "entryref")
      {
        value = pElement->Attribute("href");
        if (value != "")
        { // found an entryref, let's try loading that url
          auto_ptr<CPlayList> playlist(CPlayListFactory::Create(value));
          if (NULL != playlist.get())
//.........这里部分代码省略.........
开发者ID:Micromax-56,项目名称:xbmc,代码行数:101,代码来源:PlayListPLS.cpp

示例8: AccessXmlNode

//修改结点struNote。或返回结点struNode的值
bool CSimpleXml::AccessXmlNode( XMLNODEINFO &struNote, int nType)
{
    int nEnd = 0;
    if(m_pDoc == NULL || m_pRoot == NULL)
    {
        return false;
    }
    TiXmlText* pText = NULL; // 一个指向Text的指针
    pText = new TiXmlText(struNote.strData.c_str()) ;
    string strNodeName = struNote.strNodeName;
    nEnd = strNodeName.find("/");
    string strNode = strNodeName.substr(0, nEnd);
    strNodeName = strNodeName.substr(nEnd + 1, strNodeName.length() - nEnd);

    TiXmlNode *node = m_pRoot;
    TiXmlNode *destnode = NULL;
    while(node)
    {
        string strchildnode = node->Value();
        if(strNode != strchildnode)
        {
            node = node->NextSibling();
            continue;//此子结点非我们要的子结点,跳到下一个子结点
        }
        if((strNode == strNodeName) && (strNode == node->Value()))//Node就是我们访问的结点。
        {
            destnode = node->FirstChild();
            if(destnode && destnode->Type() == TiXmlNode::TEXT)//是叶子结点,修改为我们的值
            {
                if(nType == QUERY)
                {
                    struNote.strData = destnode->Value();//查询结点的值
                }
                else
                {
                    destnode->SetValue(struNote.strData.c_str());//修改为我们的值
                }
            }
            else if(destnode && destnode->Type() == TiXmlNode::ELEMENT)//不是叶子结点,加上我们的值
            {
                node->InsertBeforeChild(destnode, *pText);
            }
            else if(!destnode)//要写的结点原值为空,加上我们的值
            {
                node->InsertEndChild(*pText);
            }
            return true;
        }
        node = node->FirstChild();//Node不是我们访问的结点,开始遍历Node的子结点
        nEnd = strNodeName.find("/");
        strNode = strNodeName.substr(0, nEnd);
        strNodeName = strNodeName.substr(nEnd + 1, strNodeName.length() - nEnd);
        if(node && (strNode == strNodeName) && (strNode == node->Value()))//Node就是我们访问的结点
        {
            destnode = node->FirstChild();
            if(destnode && destnode->Type() == TiXmlNode::TEXT)//是叶子结点,加上我们的值
            {
                if(nType == QUERY)
                {
                    struNote.strData = destnode->Value();//查询结点的值
                }
                else
                {
                    destnode->SetValue(struNote.strData.c_str());//修改为我们的值
                }
            }
            else if(destnode && destnode->Type() == TiXmlNode::ELEMENT)//不是叶子结点,加上我们的值
            {
                node->InsertBeforeChild(destnode, *pText);
            }
            else if(!destnode)//要写的结点原值为空,加上我们的值
            {
                node->InsertEndChild(*pText);
            }
            return true;
        }
    }
    return false;
}
开发者ID:huddy1985,项目名称:ChatOnline,代码行数:80,代码来源:SimpleXml.cpp


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