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


C++ XMLElement::FirstChildElement方法代码示例

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


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

示例1: loadFile

	void Config::loadFile(const string& path)
	{
		XMLDocument document;
		if (document.LoadFile(path.c_str()) == XML_NO_ERROR) {
			XMLElement* file = document.FirstChildElement("file");
			if (file) {
				XMLElement* config = file->FirstChildElement("config");
				
				while (config) {
					const char* name = config->Attribute("name");
					if (name) {
						     if (strcmp(name, "DefaultGravity") == 0)       config->QueryDoubleAttribute("value", &Config::DefaultGravity);
						else if (strcmp(name, "PlayerMoveSpeed") == 0)      config->QueryDoubleAttribute("value", &Config::PlayerMoveSpeed);
						else if (strcmp(name, "PlayerJumpSpeed") == 0)      config->QueryDoubleAttribute("value", &Config::PlayerJumpSpeed);
						else if (strcmp(name, "MaxCrosshairDistance") == 0) config->QueryDoubleAttribute("value", &Config::MaxCrosshairDistance);
						else if (strcmp(name, "MaxGibsOnScreen") == 0)      config->QueryUnsignedAttribute("value", &Config::MaxGibsOnScreen);
						else if (strcmp(name, "GibsMin") == 0)              config->QueryIntAttribute("value", &Config::GibsMin);
						else if (strcmp(name, "GibsMax") == 0)              config->QueryIntAttribute("value", &Config::GibsMax);
						else if (strcmp(name, "BloodParticles") == 0)       config->QueryIntAttribute("value", &Config::BloodParticles);
						else if (strcmp(name, "GibMaxSpeedX") == 0)         config->QueryIntAttribute("value", &Config::GibMaxSpeedX);
						else if (strcmp(name, "GibMaxSpeedY") == 0)         config->QueryIntAttribute("value", &Config::GibMaxSpeedY);
						else if (strcmp(name, "BloodMaxSpeedX") == 0)       config->QueryIntAttribute("value", &Config::BloodMaxSpeedX);
						else if (strcmp(name, "BloodMaxSpeedY") == 0)       config->QueryIntAttribute("value", &Config::BloodMaxSpeedY);
					}
					
					config = config->NextSiblingElement("config");
				}
			}
		} else {
			cout << document.GetErrorStr1() << endl;
			cout << document.GetErrorStr2() << endl;
		}
	}
开发者ID:snosscire,项目名称:Block-World,代码行数:33,代码来源:Config.cpp

示例2: LoadXml

bool UserXml::LoadXml(std::string file)
{
	XMLDocument doc;
	XMLError e = doc.LoadFile(file.c_str());
	if (e != XML_SUCCESS)  return false;
		
	XMLElement* root = doc.RootElement();
	if (!root)  return false;

	//  clear
	trks.clear();  trkmap.clear();

	//  tracks
	const char* a;  //int i=1;  //0 = none
	XMLElement* eTrk = root->FirstChildElement("track");
	while (eTrk)
	{
		UserTrkInfo t;
		a = eTrk->Attribute("n");		if (a)  t.name = string(a);

		a = eTrk->Attribute("date");	if (a)  t.last = s2dt(a);
		a = eTrk->Attribute("rate");	if (a)  t.rating = s2i(a);
		a = eTrk->Attribute("laps");	if (a)  t.laps = s2i(a);
		a = eTrk->Attribute("time");	if (a)  t.time = s2r(a);

		trks.push_back(t);
		trkmap[t.name] = trks.size();  //i++;
		eTrk = eTrk->NextSiblingElement("track");
	}
	return true;
}
开发者ID:HaohaoLau,项目名称:stuntrally,代码行数:31,代码来源:TracksXml.cpp

示例3: load

bool TileMap::load(const char * file)
{
	this->clear();

	XMLDocument document;
	document.LoadFile(file);
	XMLElement * root = document.FirstChildElement("map");
	if(root != 0)
	{
		// base path
		strcpy(_basePath, file);
		char* p = &_basePath[strlen(file)-1];
		while(p != _basePath && *p != '/')
			p--;

		if(*p == '/')
			*p = 0;

		analyzeMapInfo(root);
		for(XMLElement* e = root->FirstChildElement(); e != 0; e = e->NextSiblingElement())
		{
			if(e->Value() == std::string("tileset"))
				this->analyzeTileset(e);
			else if(e->Value() == std::string("layer"))
				this->anylyzeLayers(e);
			else if(e->Value() == std::string("imagelayer"))
				this->anylyzeImageLayer(e);
		}
		return true;
	}
	return false;
}
开发者ID:zkl,项目名称:Gear,代码行数:32,代码来源:tilemap.cpp

示例4: SerializeStruct

void SerializeStruct(FSsPart& Value, SsXmlIArchiver* ar)
{
	SSAR_DECLARE("name", Value.PartName);
	SSAR_DECLARE("arrayIndex", Value.ArrayIndex);
	SSAR_DECLARE("parentIndex", Value.ParentIndex);

	SSAR_DECLARE_ENUM("type", Value.Type);
	SSAR_DECLARE_ENUM("boundsType", Value.BoundsType);
	SSAR_DECLARE_ENUM("inheritType", Value.InheritType);
	SSAR_DECLARE_ENUM("alphaBlendType", Value.AlphaBlendType);
	SSAR_DECLARE("show", Value.Show);
	SSAR_DECLARE("locked", Value.Locked);
	SSAR_DECLARE("refAnimePack", Value.RefAnimePack);
	SSAR_DECLARE("refAnime", Value.RefAnime);

	//継承率後に改良を実施
	if (ar->getType() == EnumSsArchiver::in)
	{
		XMLElement* e = ar->getxml()->FirstChildElement("ineheritRates");
		if (e)
		{
			XMLElement* ec = e->FirstChildElement();
			while(ec)
			{
				const char* tag = ec->Value();
				TEnumAsByte<SsAttributeKind::Type> enumattr;

				__StringToEnum_( tag , enumattr );
				Value.InheritRates[(int)enumattr] = (float)atof(ec->GetText());
				ec = ec->NextSiblingElement();
			}
		}
	}
}
开发者ID:a567w,项目名称:SS5PlayerForUnrealEngine4,代码行数:34,代码来源:SsArchiver.cpp

示例5: loadXmlElement

void LogoScene::loadXmlElement(XMLElement* rootElement)
{
    XMLElement *dicEle = rootElement->FirstChildElement();
    while (dicEle!=NULL) {
        if (dicEle->GetText()!=NULL) {
            log("dicEle Text= %s", dicEle->GetText());
            string name=dicEle->GetText();
            string png=".png";
            //判断是否是图片
            if (name.find(png)<100) {
                log("%lu 是图片",name.find(png));
                //加入缓存
                Director::getInstance()->getTextureCache()->addImageAsync(dicEle->GetText(),CC_CALLBACK_1(LogoScene::menuCloseCallback, this));
                Texture2D* texture=TextureCache::sharedTextureCache()->textureForKey(dicEle->GetText());
                if (texture) {
                    texture->setAntiAliasTexParameters();
            }
            
            
            }
            
            
        }else if (dicEle->FirstChildElement()!=NULL)
        {
            loadXmlElement(dicEle);
        }
        dicEle=dicEle->NextSiblingElement();
    }
}
开发者ID:LiZhengyan,项目名称:mycocos,代码行数:29,代码来源:LogoScene.cpp

示例6: obtener

/**
 * metodo para obtener el dato deseado
 * recibe un char* con el nombre de los nodos que se deben recorrer
 * separados por un "/" y finalizando tambien con este símbolo
 */
const char* lector::obtener(char* camino){ // siempre debe terminar con "/"
	XMLElement* elemento; //se crea un elemento temporal
	int tam=strlen(camino); //se obtiene el tamaño de la cadena de caracteres
	int inicio=0; //variable que maneja el inicio de una palabra en la cadena
	bool PrimeraPalabra=true;//bandera que sirve para identificar la primera palabra
	for(int i=0;i<tam;i++){ //ciclo para ir entranado en los nodos del XML
		if (camino[i]=='/'){ //identifica donde termina una palabra
			char dato[i-inicio]; //crea un arreglo de char del tamaño necesario para la palabra
			strncpy (dato, camino+inicio,i-inicio); // copia en dato la palabra leida de camino
			dato[i-inicio]='\0'; //agrega el caracter de escape
			if(PrimeraPalabra){ //exepcion que debe hacerse en la primera palabra
				elemento=this->doc->FirstChildElement(dato);
				if(elemento==0){
					std::cout<<"estamos en la papa"<<std::endl;
					return 0;
				}
				PrimeraPalabra=false;//indica que ya se realizo el primer caso
			}
			else{
				elemento=elemento->FirstChildElement(dato); // accede a los nodos del XML
				if(elemento==0){
					std::cout << "estamos en la segunda papa" << std::endl;
					return 0;
				}
			}
			inicio=i+1;//se mueve a la siguiente posicion del arreglo
		}
	}
	return elemento->GetText();//devulve el texto del archivo XML
}
开发者ID:fernandohv3279,项目名称:SDSM,代码行数:35,代码来源:lector.cpp

示例7: if

Scenario::Scenario()
  : m_useCharGen(false),
    m_name("DPOC")
{
  XMLDocument doc;
  if (doc.LoadFile("Scenario.xml") != 0)
  {
    throw std::runtime_error{"Fatal error: no Scenario.xml file found!"};
  }

  TRACE("Loaded scenario file");

  XMLElement* root = doc.FirstChildElement("scenario");
  for (XMLElement* element = root->FirstChildElement(); element; element = element->NextSiblingElement())
  {
    std::string tagName = element->Name();

    if (tagName == "createParty")
    {
      m_useCharGen = std::string(element->GetText()) == "true";
    }
    else if (tagName == "name")
    {
      m_name = element->GetText();
    }
  }

  TRACE(" - m_gameName   = %s", m_name.c_str());
  TRACE(" - m_useCharGen = %s", m_useCharGen ? "true" : "false");
}
开发者ID:smarmy,项目名称:DungeonCrawler,代码行数:30,代码来源:Scenario.cpp

示例8: loadTerrains

void LoadedMap::loadTerrains(XMLElement *element, TileSet *target)
{
    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTerrains start\n");

    assert(element);
    assert(target);

    XMLElement *terrain = element->FirstChildElement(XML_TERRAIN.c_str());

    Logger.logMessage(LOG_DEBUG, LOG_MAP, "LoadedMap::loadTerrains: Found first terrain\n");
    while(terrain)
    {
        TerrainType parsed_terrain;
        parsed_terrain.name = getAttributeString(terrain, XML_TERRAIN_NAME);

        stringstream tile (terrain->Attribute(XML_TERRAIN_TILE.c_str()));
        tile >> parsed_terrain.tile;

        XMLElement *properties = terrain->FirstChildElement(XML_TERRAIN_PROPS.c_str());
        if(properties)
        {
            loadTerrainProperties(properties, &parsed_terrain);
        }

        target->terraintypes.push_back(parsed_terrain);
        terrain = terrain->NextSiblingElement();
    }

    Logger.logMessage(LOG_STATE, LOG_MAP, "LoadedMap::loadTerrains end\n");
}
开发者ID:skogler,项目名称:storyofanerd2,代码行数:30,代码来源:xmlloader.cpp

示例9: carregarInformacoes

void Tiro::carregarInformacoes() {
	XMLDocument* doc = new XMLDocument();

	doc->LoadFile("tiro.svg");

	if (doc == NULL) {
		cout << "Problema ao abrir arquivo .svg\n";
		exit(1);
	}

	XMLElement* svg = doc->FirstChildElement("svg");
	if (svg == NULL) {
		cout
				<< "Erro na hora de encontrar Element 'svg'! Finalizando programa...\n";
		exit(1);
	}

	XMLElement* circleElem = svg->FirstChildElement("circle");
	if (circleElem == NULL) {
		cout
				<< "Erro na hora de encontrar Element 'circle'! Finalizando programa...\n";
		exit(1);
	}

	this->tiro->setValues(circleElem);
}
开发者ID:rbpimenta,项目名称:CG-UFES-20152-TF,代码行数:26,代码来源:Tiro.cpp

示例10: return

bool
RenderComponent::deserialize(XMLElement &n)
{
	if (!ComponentBase::deserialize(n))
	    return(false);

	XMLElement *l_child = n.FirstChildElement("mesh");
	if (!l_child) {
		MMWARNING("Render component '" << id().str() << "' deserialized without a mesh!");
		return(false);
	}

	const char *l_mesh_type = l_child->Attribute("type");
	Graphics::SharedMesh l_mesh =
	    Game::FactoryBase::Instance()->createMesh(l_mesh_type);
	if (!l_mesh) {
		MMWARNING("Render component '" << id().str() << "' has an unknown mesh type");
		return(false);
	}

	if (!l_mesh->deserialize(*l_child)) {
		MMWARNING("Render component '" << id().str() << "' deserialization of mesh failed");
		return(false);
	}

	m_p->mesh = l_mesh;

	return(true);
}
开发者ID:Kruemmelmonster,项目名称:marshmallow_h,代码行数:29,代码来源:rendercomponent.cpp

示例11: parseXML

//解析xml,id为int类型,其它属性为string类型
void ModelAttribute::parseXML(){
	if (xmldocument)
	{
		log("parseXML");
		XMLElement* root = xmldocument->RootElement();
		log("xml get root child element");
		XMLElement* att_element = root->FirstChildElement("Model");
		log("xml get first child element");
		while (att_element)
		{
			//取id
			int id = att_element->IntAttribute("ID");

			//取属性
			//			tmp_attribute_map = new std::map<std::string,int>();

			std::string sprite = att_element->Attribute("Sprite");
			tmp_attribute_map["Sprite"] = sprite;
			std::string runanimate = att_element->Attribute("Runanimate");
			tmp_attribute_map["Runanimate"] = runanimate;
			std::string dieanimate = att_element->Attribute("Dieanimate");
			tmp_attribute_map["Dieanimate"] = dieanimate;
			//将一条记录加入map
			id_map->insert(std::pair <int,std::map<std::string,std::string> >(id,tmp_attribute_map));

			//取下一个节点
			att_element = att_element->NextSiblingElement();
		}
	}
}
开发者ID:joyfish,项目名称:TowerTD,代码行数:31,代码来源:ModelAttribute.cpp

示例12: loadSettings

void Robot::loadSettings(XMLDocument* doc)
{
	printf("Robot::%s::%d: Loading Settings...\n",__INFO__);
	XMLElement* robot = doc->FirstChildElement("Robot");
	if(robot != NULL)
	{
		XMLElement* main_thread = robot->FirstChildElement("MainThread");
		if(main_thread != NULL)
		{
			double period = 0.0;
			int priority = 0;
			GET_XML_FLOAT(main_thread,Period,period,DEFUALT_MAIN_THREAD_PERIOD);
			setPeriod(period);
			GET_XML_FLOAT(main_thread,Priority,priority,DEFUALT_MAIN_THREAD_PRIORITY);
			setPriority(static_cast<gsi::Thread::ThreadPriority>(priority));
			//printf("Period is: %.3f\n",period);
			//printf("Values: %s\n",main_thread->FirstChildElement("Period")->GetText());
			//setPeriod()
		}
		else
		{
			setPeriod(DEFUALT_MAIN_THREAD_PERIOD);
			setPriority(static_cast<gsi::Thread::ThreadPriority>(DEFUALT_MAIN_THREAD_PRIORITY));
		}
	}
	else
	{
		printf("Robot::%s::%d: Error, no <Robot> element\n",__INFO__);
		printf("Robot::%s::%d: Assigning defualt settings\n",__INFO__);
		settings_file_exists = false;
	}
}
开发者ID:JosephFoster118,项目名称:RobotSoftware,代码行数:32,代码来源:Robot.cpp

示例13:

bool
SceneBase::deserialize(XMLElement &n)
{
	XMLElement *l_child;
	for (l_child = n.FirstChildElement("layer") ;
	     l_child;
	     l_child = l_child->NextSiblingElement("layer")) {

		const char *l_id   = l_child->Attribute("id");
		const char *l_type = l_child->Attribute("type");

		SharedSceneLayer l_layer =
		    FactoryBase::Instance()->createSceneLayer(l_type, l_id, *this);

		if (!l_layer) {
			MMWARNING("SceneLayer '" << l_id << "' of type '" << l_type << "' creation failed");
			continue;
		}

		if (!l_layer->deserialize(*l_child)) {
			MMWARNING("SceneLayer '" << l_id << "' of type '" << l_type << "' failed deserialization");
			continue;
		}

		pushLayer(l_layer);
	}
	
	return(true);
}
开发者ID:qrwteyrutiyoup,项目名称:marshmallow_h,代码行数:29,代码来源:scenebase.cpp

示例14: example_4

bool example_4()
{
	static const char* xml =
		"<information>"
		"	<attributeApproach v='2' />"
		"	<textApproach>"
		"		<v>2</v>"
		"	</textApproach>"
		"</information>";

	XMLDocument doc;
	doc.Parse( xml );

	int v0 = 0;
	int v1 = 0;

	XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
	attributeApproachElement->QueryIntAttribute( "v", &v0 );

	XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
	textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );

	printf( "Both values are the same: %d and %d\n", v0, v1 );

	return !doc.Error() && ( v0 == v1 );
}
开发者ID:Redee,项目名称:RdEngine,代码行数:26,代码来源:xmltest.cpp

示例15: _configureSinusoidal

void CEnvironment::_configureSinusoidal ( void ){ 	
	/* Read components from XML file */
	XMLDocument conf;
    	conf.LoadFile( m_sSourceFile.c_str() );
	XMLElement* root = conf.FirstChildElement();
	string   elemName, attr;
	SFreqCmp tmp_FC;
	for( XMLElement* elem = root->FirstChildElement() ; elem != NULL ; elem = elem->NextSiblingElement() ){
		elemName = elem->Value();
		if ( elemName == "Cmp" ){
			attr          = elem->Attribute("period");
			tmp_FC.period = atof( attr.c_str() ) / float ( m_nSampling );
			attr          = elem->Attribute("phase");
			tmp_FC.phs    = atof( attr.c_str() );
			attr          = elem->Attribute("amplitude");
			tmp_FC.amp    = m_fAmplitude * atof( attr.c_str() );
			if ( tmp_FC.period > 0.0 ){
				m_vInputSignal [ int ( float( m_nFFTsize  ) / tmp_FC.period ) ] = tmp_FC;
				m_vNCAmp       [ int ( float( m_nFFTsize  ) / tmp_FC.period ) ] = tmp_FC.amp;
			}
			else{
				m_vInputSignal [ 0 ] = tmp_FC;
				m_vNCAmp       [ 0 ] = tmp_FC.amp;

			}
		}
	}
	return;
};
开发者ID:mccagigal,项目名称:mufco,代码行数:29,代码来源:environment.cpp


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