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


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

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


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

示例1: Create_From_Stream

 void cMushroom::Create_From_Stream(XMLElement* attributes)
 {
     int posx = 0, posy = 0;
     
     int mushroom_type = TYPE_MUSHROOM_DEFAULT;
     
     for (XMLElement* node = attributes->FirstChildElement(); node; node = node->NextSiblingElement())
     {
         const char* name = node->Attribute("name");
         const char* value = node->Attribute("value");
     
         if (!strcmp(name, "posx"))
         {
             posx = atoi(value);
         }
         else if (!strcmp(name, "posy"))
         {
             posy = atoi(value);
         }
         else if (!strcmp(name, "mushroom_type"))
         {
             mushroom_type = atoi(value);
         }
     }
     
     Set_Pos(static_cast<float>(posx), static_cast<float>(posy));
     
     Set_Type(static_cast<SpriteType>(mushroom_type));
 }
开发者ID:chrislee1018,项目名称:smcios,代码行数:29,代码来源:powerup.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: LoadLink

string XMLHandler::LoadLink(string name)
{
    XMLDocument doc;
    doc.LoadFile("links.xml");
    if( doc.Error() )
    {
        cout << "\nERROR:" << doc.ErrorID() << endl;
        return "ERROR";
    }

    XMLElement* rootNode = doc.FirstChildElement("Links");
    if (!rootNode) std::cout << "No Links element" << std::endl;

    XMLElement* linkNode = rootNode->FirstChildElement("Link");
    if(!linkNode) std::cout << "No link elements" << std::endl;

    // Loop through XML
    for( ; linkNode != NULL; linkNode = linkNode->NextSiblingElement() )
    {
        if( name == linkNode->Attribute("name") )
        {
            return linkNode->Attribute("url");
        }
    }

    return "NOTFOUND";
}
开发者ID:noxshroom,项目名称:TikoIrcBot,代码行数:27,代码来源:XMLHandler.cpp

示例4: readConfigXML

Stadium* Scanner::readConfigXML(string file)
{
    string name, type, path;
    double shot, move;
    double npcVel, shotNpc, alturaObstaculo, freqTiro;

    doc.LoadFile(file.data());
    if(!doc.ErrorID())
    {
        XMLElement* arena = doc.FirstChildElement("aplicacao")->FirstChildElement("arquivoDaArena");
        name = arena->Attribute("nome");
        type = arena->Attribute("tipo");
        path = arena->Attribute("caminho");
        XMLElement* player = doc.FirstChildElement("aplicacao")->FirstChildElement("jogador");
        player->QueryDoubleAttribute("velTiro",&shot);
        player->QueryDoubleAttribute("vel",&move);

        XMLElement* inimigo = doc.FirstChildElement("aplicacao")->FirstChildElement("inimigo");
        inimigo->QueryDoubleAttribute("velTiro",&shotNpc);
        inimigo->QueryDoubleAttribute("vel",&npcVel);
        inimigo->QueryDoubleAttribute("freqTiro",&freqTiro);

        XMLElement* obstacle = doc.FirstChildElement("aplicacao")->FirstChildElement("obstaculo");
        obstacle->QueryDoubleAttribute("altura",&alturaObstaculo);
        return readArenaSVG(path + name +"."+type,shot,move,shotNpc,npcVel,alturaObstaculo,freqTiro);
  }else
    {
        cout << "Erro ao abrir o arquivo XML "<< file << "\n";
        exit(1);
    }

}
开发者ID:igorventorim,项目名称:UFES,代码行数:32,代码来源:Scanner.cpp

示例5: parseOPF

void Book::parseOPF(BLUnZip& zip)
{
    std::string data = zip.ExtractToString(m_opf);
    
    XMLDocument doc;
    doc.Parse(data.c_str());

    XMLElement* package = doc.FirstChildElement("package");
    XMLElement* metadata = package->FirstChildElement("metadata");
    XMLElement* manifest = package->FirstChildElement("manifest");
    XMLElement* item = manifest->FirstChildElement("item");

    m_title = metadata->FirstChildElement("dc:title")->GetText();
    m_author = metadata->FirstChildElement("dc:creator")->GetText();

    for(XMLElement* rfe = item; rfe != nullptr; rfe = rfe->NextSiblingElement("item"))
    {
       m_manifest.emplace(rfe->Attribute("id"), rfe->Attribute("href"));
    }

    XMLElement* spine = package->FirstChildElement("spine");
    XMLElement* itemref = spine->FirstChildElement("itemref");

    for (XMLElement* it = itemref; it != nullptr; it = it->NextSiblingElement("itemref"))
    {
        m_spine.push_back(it->Attribute("idref"));
    }
}
开发者ID:reworks,项目名称:3DS_eBook_Reader,代码行数:28,代码来源:Book.cpp

示例6: getGeom

// Initialize a Geometry class given an XML element, return IQM file name
static Geometry getGeom(XMLElement *elGeom){
	Geometry G;

	XMLElement * trEl = check("Transform", elGeom);
	vec3 T(safeAtoF(*trEl, "Tx"), safeAtoF(*trEl, "Ty"), safeAtoF(*trEl, "Tz"));
	vec3 S(safeAtoF(*trEl, "Sx"), safeAtoF(*trEl, "Sy"), safeAtoF(*trEl, "Sz"));
	vec3 R(safeAtoF(*trEl, "Rx"), safeAtoF(*trEl, "Ry"), safeAtoF(*trEl, "Rz"));
	float rot = safeAtoF(*trEl, ("R"));
	mat4 M = glm::translate(T) * glm::rotate(rot, R) * glm::scale(S);

	// Create a Material
	XMLElement * matEl = check("Material", elGeom);
	float shininess(safeAtoF(*matEl, "shininess"));
	float reflectivity(safeAtoF(*matEl, "reflectivity"));
	vec4 diff(safeAtoF(*matEl, "Dr"), safeAtoF(*matEl, "Dg"), safeAtoF(*matEl, "Db"), safeAtoF(*matEl, "Da"));
	vec4 spec(safeAtoF(*matEl, "Sr"), safeAtoF(*matEl, "Sg"), safeAtoF(*matEl, "Sb"), safeAtoF(*matEl, "Sa"));
	Material mat(shininess, reflectivity, diff, spec);
	if (matEl->Attribute("Texture"))
		mat.SetTexMapSrc(matEl->Attribute("Texture"));
	if (matEl->Attribute("Normal"))
		mat.SetNrmMapSrc(matEl->Attribute("Normal"));

	// Set values
	G = Geometry("../Resources/IQM/" + string(elGeom->Attribute("fileName")));
	G.leftMultM(M);
	G.setMaterial(mat);

	return G;
}
开发者ID:mynameisjohn,项目名称:SDL2_XML_Renderer,代码行数:30,代码来源:Scene.cpp

示例7: Create_From_Stream

void cEato::Create_From_Stream(XMLElement* attributes)
{
    int posx = 0, posy = 0;
    std::string image_dir = m_img_dir;
    std::string direction = Get_Direction_Name(m_start_direction);

    for (XMLElement* node = attributes->FirstChildElement(); node; node = node->NextSiblingElement())
    {
        const char* name = node->Attribute("name");
        const char* value = node->Attribute("value");

        if (!strcmp(name, "posx"))
        {
            posx = atoi(value);
        }
        else if (!strcmp(name, "posy"))
        {
            posy = atoi(value);
        }
        else if (!strcmp(name, "image_dir"))
        {
            image_dir = value;
        }
        else if (!strcmp(name, "direction"))
        {
            direction = value;
        }
    }

    Set_Pos(static_cast<float>(posx), static_cast<float>(posy), 1);
    Set_Image_Dir(image_dir.c_str());
    Set_Direction(Get_Direction_Id(direction.c_str()));
}
开发者ID:chrislee1018,项目名称:smcios,代码行数:33,代码来源:eato.cpp

示例8: SetId

void 
GameObject::Load( XMLElement & e )
{
  const char * attrib = e.Attribute("id");  
  if ( !attrib ) throw AttributeMissingException("Attribute id is missing!");
  SetId(attrib);

  attrib = e.Attribute("description");
  if ( !attrib ) throw AttributeMissingException("Attribute description is missing!");
  SetDescription(attrib);

  attrib = e.Attribute("name");
  if ( !attrib ) throw AttributeMissingException("Attribute name is missing!");
  SetName(attrib);
  
  attrib = e.Attribute("match");
  if ( attrib) 
  {
    SetNamePattern(attrib);
  }
  
  // Load properties 
  XMLElement *props = e.FirstChildElement("Properties");
  if ( props )  LoadProperties( *props);

  XMLElement *items = e.FirstChildElement("Items");
  if ( items ) LoadItems(*items);
  else g_Log << "There were no items...\n";
}
开发者ID:Caennalla,项目名称:sdlcoursetasks,代码行数:29,代码来源:GameObject.cpp

示例9: _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

示例10: while

XMLElement * Utils::w(XMLElement * element, const char * name, const char * attribute, const char * value){
    XMLElement * sibilingElement = element->NextSiblingElement(name);

    while (sibilingElement != NULL && strcmp(sibilingElement->Attribute(attribute), value) != 0) {
        sibilingElement = sibilingElement->NextSiblingElement(name);
    }
    return sibilingElement == NULL || strcmp(sibilingElement->Attribute(attribute), value) != 0 ? NULL : sibilingElement;
}
开发者ID:danfergo,项目名称:HSTTScheduler,代码行数:8,代码来源:Utils.cpp

示例11: readHelicopterConfig

Helicopter XMLConfig::readHelicopterConfig(const char * path){
	XMLDocument doc;
	doc.LoadFile(path);

	XMLElement* helicoptero = doc.FirstChildElement("aplicacao")->FirstChildElement("helicoptero");
	Helicopter h = Helicopter(atof(helicoptero->Attribute("velTiro")),
								atof(helicoptero->Attribute("velHelicoptero")),
								atof(helicoptero->Attribute("tempoDeVoo")));
	return h;
}
开发者ID:BrunoAgrizzi,项目名称:cg-tf,代码行数:10,代码来源:XMLConfig.cpp

示例12:

int
CSettings::ParseOutputs(XMLElement *Outputs)
{
	// Parse Outputs
	XMLElement *Output = Outputs->FirstChildElement("output");

	int NumberOfOutputs = 0;
	while(Output)
	{
		OutputContainer OutputParse;
		NumberOfOutputs++;

		if(!Output->Attribute("name"))
		{
			Log.error("Output entry has no name\n");
			return false;
		}

		// Check if there is a duplicate name
		OutputParse.name = Output->Attribute("name");
		for(list<OutputContainer>::iterator i=OutputsDB.begin(); i != OutputsDB.end(); ++i)
		{
			if(OutputParse.name.compare((*i).name) == 0)
			{
				Log.error("Duplicate output name [%s]\n", OutputParse.name.c_str());
				return false;
			}
		}


		OutputParse.type = Output->Attribute("type");

		XMLNode *OutSettings = Output->FirstChild();

		while(OutSettings)
		{
			if(OutSettings->Value() && OutSettings->ToElement()->GetText())
			{
				OutputParse.settings[OutSettings->Value()] = OutSettings->ToElement()->GetText();
				Log.debug("parsed [%s]=[%s]", OutSettings->Value(), OutputParse.settings[OutSettings->Value()].c_str());
			}

			OutSettings = OutSettings->NextSibling();
		}

		OutputsDB.push_back(OutputParse);

		Output = Output->NextSiblingElement("output");
	}


	Log.log("Parsed %d outputs\n", NumberOfOutputs);

	return true;
}
开发者ID:alxnik,项目名称:fpd,代码行数:55,代码来源:CSettings.cpp

示例13: readXMLDoc

TestData readXMLDoc() {

    XMLDocument doc;
#ifdef WIN32
    XMLCheckResult(doc.LoadFile("../../test/mpw_tests.xml"));
#else
    XMLCheckResult(doc.LoadFile("mpw_tests.xml"));
#endif

    TestData data;
    XMLNode * pRoot = doc.FirstChild();
    if (pRoot == 0) return data;

    XMLElement * pListElement = pRoot->FirstChildElement("case");
    TestData testData;

    while (pListElement != 0) {
        //We have a test case. Allocate memory for it.
        TestCase testCase;

        //Get the ID of this case
        std::string id = pListElement->Attribute("id");
        std::cout << "ID: " << id << std::endl;

        //Now check if we have a parent.
        const char* pParent = pListElement->Attribute("parent");
        if (pParent) {
            testCase = testData.at(pParent);
        }

        //Now fill in the data from this node.
        XMLElement * pNodeListElement = pListElement->FirstChildElement();
        while (pNodeListElement != 0) {
            const char* name = pNodeListElement->Name();
            const char* value = pNodeListElement->GetText();
            if (value != 0) {
                testCase[name] = value;
                std::cout << name << ": " << testCase[name] << std::endl;
            }
            else {
                testCase[name] = "";
                std::cout << name << ": " << "null" << std::endl;
            }
            pNodeListElement = pNodeListElement->NextSiblingElement();
        }

        testData[id] = testCase;

        pListElement = pListElement->NextSiblingElement("case");
    }

    return testData;
}
开发者ID:cuardin,项目名称:MasterPassword02,代码行数:53,代码来源:StandardizedTestSuite.cpp

示例14: readEnemyHelicopter

Helicopter XMLConfig::readEnemyHelicopter(const char* path, float cx, float cy){
	XMLDocument doc;
	doc.LoadFile(path);
	XMLElement* helicoptero = doc.FirstChildElement("aplicacao")->FirstChildElement("helicopteroInimigo");
	Helicopter h =
		Helicopter(atof(helicoptero->Attribute("freqTiro")),
					atof(helicoptero->Attribute("velHelicoptero")),
					cx,
					cy);
	// <helicopteroInimigo freqTiro="0.0001" velHelicoptero="0.1"></helicopteroInimigo>
	return h;
}
开发者ID:BrunoAgrizzi,项目名称:cg-tf,代码行数:12,代码来源:XMLConfig.cpp

示例15: LoadTriggersConfig

	void TriggerManager::LoadTriggersConfig(const std::string& moduleDir, std::vector<TriggerParameters>& trigsParams)
	{

		trigsParams.clear();

		std::string file(moduleDir + "triggersConfig.xml");

		XMLDocument doc;

		if(doc.LoadFile(file.c_str()) != XML_SUCCESS)
		{
			throw -1;
		}

		XMLElement* root = doc.RootElement();

		// Look for first trigger
		XMLElement* firstTrigger = root->FirstChildElement("Trigger");

		// Read all triggers
		for(XMLElement* trigger = firstTrigger; trigger != nullptr; trigger = trigger->NextSiblingElement())
		{
			TriggerParameters trigParams;

			// Get trigger id
			trigParams.sensorId = std::atoi(trigger->Attribute("sensorId"));

			// Get trigger type
			trigParams.type = Util::Enums::TriggerTypeFromString(trigger->Attribute("sensorType"));

			// Read xml elements
			XMLElement* threshold = trigger->FirstChildElement("Threshold");
			XMLElement* scanTime = trigger->FirstChildElement("ScanTime");
			XMLElement* maskTime = trigger->FirstChildElement("MaskTime");
			XMLElement* response = trigger->FirstChildElement("Response");

			trigParams.threshold = (short) std::atoi(threshold->GetText());
			trigParams.scanTime = (unsigned int) std::atoi(scanTime->GetText());
			trigParams.maskTime = std::atoi(maskTime->GetText());
			trigParams.response = Util::Enums::CurveTypeFromString(response->GetText());

			//XXX Reading only sensor type
			LoadSensorsConfig(moduleDir, trigParams.sensorType);
			//trigParams.sensorType = IO::SensorType::Hdd;

			trigsParams.push_back(trigParams);
		}


		return;
	}
开发者ID:SpintroniK,项目名称:libeXaDrums,代码行数:51,代码来源:TriggerManager.cpp


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