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


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

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


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

示例1: treatOneLanguage

/** Get all the language nodes and call TreatOneLanguage for each one
  *
  */
void RainbruRPG::Options::xmlLanguage::treatAllLanguages(){
  TiXmlNode* childNode = root->FirstChild( "Language" );
  if (childNode){
    TiXmlElement* child= childNode->ToElement();
    for( child; child; child=child->NextSiblingElement() ){
      treatOneLanguage(child);
    }

  }
  else{
    LOGW(_("Empty language list found"));
  }

}
开发者ID:dreamsxin,项目名称:rainbrurpg,代码行数:17,代码来源:XmlLanguage.cpp

示例2: LoadSounds

void zzzSndSystem::LoadSounds()
{
	//read xml & load sets
	DataStreamPtr data = ResourceGroupManager::getSingleton().openResource("sounds.xml");
	String str = data->getAsString();
	TiXmlDocument doc;
	doc.Parse(str.c_str());

	if (!doc.Error())
	{
		TiXmlNode* node;
		node=doc.FirstChild();
		node=node->FirstChild();
		for (;node!=0;node=node->NextSibling()) 
		{
			if (node->Type() == TiXmlNode::ELEMENT)
			{
				//get params
				String name = "";
				String file = "";

				if (strcmp(node->Value(), "sound") == 0)
				{
					TiXmlAttribute* att = node->ToElement()->FirstAttribute();
					while (att)
					{
						if (strcmp(att->Name(), "name") == 0)
						{
							name = att->Value();
						}
						else if (strcmp(att->Name(), "file") == 0)
						{
							file = att->Value();
						}
						att = att->Next();
					}

					if (name.length() > 0)
					{
						SND->LoadSound(name, file);
					}
				}
			}
		}
	}
	else
	{
		throw Exception(Exception::ERR_FILE_NOT_FOUND, std::string(doc.ErrorDesc()) + " : particles.xml", __FUNCTION__);
	}
}
开发者ID:drwbns,项目名称:1stperson,代码行数:50,代码来源:zzzSndSystem.cpp

示例3: XMLProcessBackground

void MSBInfo::XMLProcessBackground(TiXmlNode* bg)
{
	if (bg)
	{
		TiXmlNode* child = 0;
		_page->Text = "";
		while((child = bg->IterateChildren(child)))
		{
			if (child->ValueStr().compare("avobject") == 0)
			{
				TiXmlElement* av = child->ToElement();
				_page->Image = av->Attribute("filename");
			}
			if (child->ValueStr().compare("txt") == 0)
			{
				TiXmlElement* txt = child->ToElement();
				_page->Text += txt->GetText();
			}
		}
	}
	else
		Core::Dbg->Log(Warning, "NULL value passed to utterance node handler");
}
开发者ID:rpheuts,项目名称:PSPFramework,代码行数:23,代码来源:msbinfo.cpp

示例4: LoadAlgorithmSettings

/**
 Wczytuje atrybuty algorytmu.
 Wczytana zostaje miedzy innymi nazwa alogrytmu.
 
 @param algo Wskaznik do konfigurowanego algorytmu
*/
void XMLConfigFile::LoadAlgorithmSettings(Algorithm* algo) {
    TRACE( "XMLConfigFile::LoadAlgorithmSettings - Wczytywanie ustawien algorytmu...\n" );
	TiXmlElement* algoXmlElem;
	TiXmlNode* algoXmlNode;
	string algoName;

    TiXmlHandle docHandle( &document );
	algoXmlNode = docHandle.FirstChild( "algorithm" ).Node();
	if(algoXmlElem != NULL) {
       	algoXmlElem = algoXmlNode->ToElement();
		if( algoXmlElem->Attribute("name") )
			algo->SetName( algoXmlElem->Attribute("name") );
	}
}
开发者ID:BackupTheBerlios,项目名称:pgrtsound-svn,代码行数:20,代码来源:xmlconfigfile.cpp

示例5: StreamIn

void TiXmlDocument::StreamIn(std::istream * in, TIXML_STRING * tag) {
    // The basic issue with a document is that we don't know what we're
    // streaming. Read something presumed to be a tag (and hope), then
    // identify it, and call the appropriate stream method on the tag.
    //
    // This "pre-streaming" will never read the closing ">" so the
    // sub-tag can orient itself.

    if (!StreamTo(in, '<', tag)) {
        SetError(TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
        return;
    }

    while (in->good()) {
        int tagIndex = (int) tag->length();
        while (in->good() && in->peek() != '>') {
            int c = in->get();
            if (c <= 0) {
                SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
                break;
            }
            (*tag) += (char) c;
        }

        if (in->good()) {
            // We now have something we presume to be a node of 
            // some sort. Identify it, and call the node to
            // continue streaming.
            TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);

            if (node) {
                node->StreamIn(in, tag);
                bool isElement = node->ToElement() != 0;
                delete node;
                node = 0;

                // If this is the root element, we're done. Parsing will be
                // done by the >> operator.
                if (isElement) {
                    return;
                }
            } else {
                SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
                return;
            }
        }
    }
    // We should have returned sooner.
    SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
}
开发者ID:wugang33,项目名称:cepframe,代码行数:50,代码来源:tinyxmlparser.cpp

示例6: doc

const String& MimeType::comment(void) {
	// calling without mime loaded do nothing
	if(!(status & MIME_LOADED))
		return mcmt;

	if(status & COMMENT_LOADED)
		return mcmt;

	String ttype = mtype;
	ttype += ".xml";

	const char* p = xdg_mime_find_data(ttype.c_str());
	if(!p)
		return mcmt;

	String path = p;
	
	TiXmlDocument doc(path.c_str());

	if(!doc.LoadFile()) {
		E_DEBUG(E_STRLOC ": MimeType::comment() %s malformed\n", path.c_str());
		return mcmt;
	}

	TiXmlNode* el = doc.FirstChild("mime-type");

	/*
	 * First element which does not have "xml:lang" attribute
	 * is default one. So hunt that one :)
	 *
	 * Btw. TinyXML does not handle XML namespaces and will return
	 * "<namespace>:<attribute>" value. This is not big deal as long
	 * as correctly fetch attribute values.
	 */
	for(el = el->FirstChildElement(); el; el = el->NextSibling()) {
		if(strncmp(el->Value(), "comment", 7) == 0) {
			// TODO: add locale here
			if(!el->ToElement()->Attribute("xml:lang")) {
				TiXmlText* data = el->FirstChild()->ToText();
				if(data) {
					mcmt = data->Value();
					break;
				}
			}
		}
	}

	status |= COMMENT_LOADED;
	return mcmt;
}
开发者ID:edeproject,项目名称:svn,代码行数:50,代码来源:MimeType.cpp

示例7: TiXmlFindElement

	TiXmlElement* TiXmlFindElement(TiXmlDocument* doc, const xdl_char* elements) {
		std::vector<std::string> tokens;
		size_t number = xstd::tokenize(elements, tokens, "/");
		TiXmlNode* child = doc;
		size_t count = 0;
		while(count < number) {
			child = child->FirstChild(tokens[count].c_str());
			count++;;
		}
		if(child != NULL)
			return child->ToElement();

		return NULL;
	}
开发者ID:yaakuro,项目名称:XdevLSDK,代码行数:14,代码来源:XdevLUtils.cpp

示例8: StreamOut

void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const
{
	TiXmlNode* node;
	for ( node=FirstChild(); node; node=node->NextSibling() )
	{
		node->StreamOut( out );

		// Special rule for streams: stop after the root element.
		// The stream in code will only read one element, so don't
		// write more than one.
		if ( node->ToElement() )
			break;
	}
}
开发者ID:125radheyshyam,项目名称:notepad-plus-plus,代码行数:14,代码来源:tinyxml.cpp

示例9: treatCountry

/** Treat all countries of a single language
  *
  */
void RainbruRPG::Options::xmlLanguage::
treatLanguageCountries(TiXmlElement* e, const LanguageListItem& it){
  TiXmlNode* childNode = e->FirstChild( "Country" );
  if (childNode){
    TiXmlElement* child= childNode->ToElement();
    for( child; child; child=child->NextSiblingElement() ){
      treatCountry(child, it);
    }

  }
  else{
    LOGW(_("Empty country list found"));
  }
}
开发者ID:dreamsxin,项目名称:rainbrurpg,代码行数:17,代码来源:XmlLanguage.cpp

示例10: Get

const char* CXmlSiblingElemIter::Get(const char* szElemName)const
{
	const char* szText=NULL;

	if (m_pCurNode)
	{
		TiXmlNode* pNode = m_pCurNode->FirstChildElement( szElemName );
		if (pNode)
		{
			szText = pNode->ToElement()->GetText();
		}
	}
	return szText;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:14,代码来源:CXmlConfig.cpp

示例11: FindLNType

int CXGseScd::FindLNType(TiXmlNode *pLN0Node, const std::string &prefix, const std::string &ln_class, const std::string &ln_inst, const std::string &do_name, std::string &ds_desc, std::string &ln_type)
{
    TiXmlNode *pXmlLNNode = pLN0Node->NextSibling("LN");
    TiXmlElement *pLNElement = NULL;
    while (pXmlLNNode != NULL)
    {
        pLNElement = pXmlLNNode->ToElement();
        if ((ln_class == pLNElement->Attribute("lnClass"))
            && (ln_inst == pLNElement->Attribute("inst"))
            && ((prefix == "")
            || (prefix == pLNElement->Attribute("prefix"))))
        {
            ln_type = pLNElement->Attribute("lnType");
            TiXmlNode *pDONode = pXmlLNNode->FirstChild("DOI");
            while (pDONode != NULL)
            {
                if (pDONode->ToElement()->Attribute("name") == do_name)
                {
                    TiXmlNode *pDANode = pDONode->FirstChild("DAI");
                    while (pDANode != NULL)
                    {
                        if (pDANode->ToElement()->Attribute("name") == std::string("dU"))
                        {
                            ds_desc = pDANode->FirstChildElement("Val")->GetText();
                            break;
                        }
                        pDANode = pDANode->NextSibling();
                    }
                    return J_OK;
                }
                pDONode = pDONode->NextSibling();
            }
        }
        pXmlLNNode = pXmlLNNode->NextSibling("LN");
    }
    return J_NOT_FOUND;
}
开发者ID:dulton,项目名称:jorhy-prj,代码行数:37,代码来源:x_gse_scd.cpp

示例12: save_game

void GameIntro::save_game(std::string & filename){
	// vytvorit dokument
	TiXmlDocument doc;
	doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
	// element game
	TiXmlNode *node;
	TiXmlElement *el, *rootEl;
	node = doc.InsertEndChild(TiXmlElement("game"));
	if(!node)
		TiXmlError("can't create root element");
	rootEl = node->ToElement();
	rootEl->SetAttribute("episode", cur_episode_);
	rootEl->SetAttribute("level", cur_level_);
	// elementy hracu
	std::string el_name;
	PlayerProperties prop;
	for(Uint16 i = 0 ; i < players_count_ ; ++i){
		el_name = "player"+x2string(i);
		node = rootEl->InsertEndChild(TiXmlElement(el_name.c_str()));
		if(!node)
			TiXmlError("can't create element "+el_name);
		el = node->ToElement();
		// atributy
		gameBase_->get_player(i, prop);
		el->SetAttribute("lives", prop.lives);
		el->SetAttribute("flames", prop.flames);
		el->SetAttribute("bombs", prop.bombs);
		el->SetAttribute("boots", prop.boots);
	}
	// ulozit do souboru
	try {
		TiXmlSaveDocument(doc, filename);
	}
	catch(const std::string & err){
		TiXmlError(filename, err);
	}
}
开发者ID:jirkadanek,项目名称:bombic2,代码行数:37,代码来源:game_intro.cpp

示例13: parseImpl

void BulletMLParserTinyXML::parseImpl(TiXmlDocument& doc) {
	if (doc.Error()) {
#ifdef __EXCEPTIONS
		throw BulletMLError(doc.Value() + ": " + doc.ErrorDesc());
#endif
	}

    TiXmlNode* node;
    for (node = doc.FirstChild(); node; node = node->NextSibling()) {
		if (node->ToElement() != 0) {
			getTree(node);
			break;
		}
    }
}
开发者ID:Bracket-,项目名称:psp-ports,代码行数:15,代码来源:bulletmlparser-tinyxml.cpp

示例14: loadConfig

void Config::loadConfig(String configNamespace, String fileName) {
	TiXmlDocument doc(fileName.c_str());
	
	Logger::log("Loading config: %s\n", fileName.c_str());
	
	if(!doc.LoadFile()) {
		Logger::log("Error loading config file...\n");
		Logger::log("Error: %s\n", doc.ErrorDesc());
		return;
	}
	
	TiXmlElement *rootElement = doc.RootElement();
	
	TiXmlNode *pChild;
	ConfigEntry *entry;
	for(pChild = rootElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		entry = getEntry(configNamespace, pChild->Value());
		entry->stringVal = pChild->ToElement()->GetText();		
		entry->numVal = atof(pChild->ToElement()->GetText());
		entry->isString = true;
		entry->configNamespace = configNamespace;
	}
	
}
开发者ID:RobLach,项目名称:Polycode,代码行数:24,代码来源:PolyConfig.cpp

示例15: LoadRects

/*
	функция считывает  прямоугольники из файла out_r.xml 
	в массив g_rects
*/
void LoadRects(int w, int h)
{
   TiXmlDocument doc("out_r.xml");
   if (!doc.LoadFile())
    return;	

   TiXmlHandle hDoc(&doc);
   TiXmlElement* pElem = NULL;
   TiXmlHandle hRoot(0);

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
	   return;
   if (strcmp(pElem->Value(), "Rects") != 0)
	   return;
   int count = 0;
   double v = 0;
   for (TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling())
   {
	   if (strcmp(child->Value(), "rect") != 0)
		   continue;
	   child->ToElement()->QueryDoubleAttribute("x",&v);
	   g_rects[count].x = (int)(w*v/100.);
	   child->ToElement()->QueryDoubleAttribute("y",&v);
	   g_rects[count].y = (int)(h*v/100.);
	   child->ToElement()->QueryDoubleAttribute("w",&v);
	   g_rects[count].width = (int)(w*v/100.);
	   child->ToElement()->QueryDoubleAttribute("h",&v);
	   g_rects[count].height = (int)(h*v/100.);
	   count++;
	   if (count > C_MAX_OBJECTS)
		   break;
   }
   g_rects_count = count;
   MakeMaskImage(g_mask);
}
开发者ID:telnykha,项目名称:VideoA,代码行数:40,代码来源:test_recorder.cpp


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