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


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

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


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

示例1: loadFont

	void Font::loadFont( const char* xmlFile )
	{
		XMLParser parser( xmlFile );
		XMLDocument& doc = parser.getDocument();		
		
		if( !doc.Error() )
		{		
			XMLNode* root = doc.FirstChildElement( "FontDefinition" );
			XMLNode* fontInfo = root->FirstChildElement( "FontInfo" );
			m_fontName = parser.getXMLAttributeAsString( fontInfo, "name", "" );
			m_fontLocale = parser.getXMLAttributeAsString( fontInfo, "local", "en" );
			m_pixelHeight = parser.getXMLAttributeAsInt( fontInfo, "cellPixelHeight", 1 );


			XMLNode* element; 
			for( element = root->FirstChildElement( "Glyph" ); element != 0; element = element->NextSiblingElement( "Glyph" ) )
			{
				Glyph g = loadGlyph( parser, element );
				m_glyphs.insert( std::pair< unsigned char, Glyph >( g.ucsIndex, g ) );
			}
		}
		else
		{
			MonkyException::simpleErrorMessageBox( "Failed to load font", "File could not be opened" );
		}
	}
开发者ID:hulcyp,项目名称:GuildhallProjects,代码行数:26,代码来源:Font.cpp

示例2: deserialize

 void Rigidbody::deserialize(XMLNode* node) {
     XMLNode* t = node->FirstChildElement("Velocity");
     t->FirstChildElement("X")->QueryFloatText(&(this->velocity.x));
     t->FirstChildElement("Y")->QueryFloatText(&this->velocity.y);
     t = node->FirstChildElement("Acceleration");
     t->FirstChildElement("X")->QueryFloatText(&(this->acceleration.x));
     t->FirstChildElement("Y")->QueryFloatText(&this->acceleration.y);
     node->FirstChildElement("RadialVelocity")->QueryFloatText(&this->radialVelocity);
 }
开发者ID:TravisForkner,项目名称:Raven2015,代码行数:9,代码来源:ComponentLibrary.cpp

示例3: parser

//---------------------------------------------------------------------------------
SpriteAnimation::SpriteAnimation( const std::string& animationFile )
    :	m_frameRate( 0.0f )
    ,	m_isLoop( false )
    ,	m_material( "" )
    , 	m_isPlaying( false )
    ,	m_lastFrameTime( 0.0f )
    ,	m_currentFrameNumber( 0 )
{
    XMLParser parser( animationFile.c_str(), false );
    XMLDocument& doc = parser.getDocument();

    if( !doc.Error() )
    {
        consolePrintf( "Loading animation: %s", animationFile.c_str() );
        XMLNode* animation = doc.FirstChildElement( "Animation" );
        parser.validateXMLAttributes( animation, "frameRate,material", "isLooping,startPlaying" );
        parser.validateXMLChildElements( animation, "Frame", "" );

        float frameRate = parser.getXMLAttributeAsFloat( animation, "frameRate", 0.0f );
        bool isLooping = parser.getXMLAttributeAsBool( animation, "isLooping", false );
        bool startPlaying = parser.getXMLAttributeAsBool( animation, "startPlaying", false );
        std::string material = parser.getXMLAttributeAsString( animation, "material", "" );

        m_frameRate = frameRate;
        m_isLoop = isLooping;
        m_material = material;

        XMLNode* frame;
        for( frame = animation->FirstChildElement( "Frame" ); frame != nullptr; frame = frame->NextSiblingElement( "Frame" ) )
        {
            parser.validateXMLChildElements( frame, "TexCoords", "Material" );
            XMLNode* texCoords = frame->FirstChildElement( "TexCoords" );
            XMLNode* material = frame->FirstChildElement( "Material" );
            parser.validateXMLAttributes( texCoords, "topLeft,width,height", "" );
            vec2f topLeft = parser.getXMLAttributeAsVec2( texCoords, "topLeft", vec2f() );
            float width = parser.getXMLAttributeAsFloat( texCoords, "width", 1.0f );
            float height = parser.getXMLAttributeAsFloat( texCoords, "height", 1.0f );

            std::string materialName;
            if( material != nullptr )
            {
                parser.validateXMLAttributes( material, "name", "" );
                materialName = parser.getXMLAttributeAsString( material, "name", "" );

            }
            AddFrame( topLeft, width, height, materialName );
        }

        if( startPlaying )
        {
            Play();
        }
        consolePrintf( "Successfully loaded animation: %s", animationFile.c_str() );
    }
}
开发者ID:hulcyp,项目名称:GuildhallProjects,代码行数:56,代码来源:SpriteAnimation.cpp

示例4: initialize

bool AudioResourceManager::initialize()
{
    srand(time(NULL));
    Ogre::String path = Ogre::macBundlePath() + "/Contents/Resources/media/config/audio_events.xml";
    //xml_document<> doc;    // character type defaults to char
    FILE *audioConfigFile = fopen(path.data(), "r");
    
    std::vector<char> buffer;
    int c;
    while (EOF !=(c=getc(audioConfigFile))){
        buffer.push_back(c);
    }
   
    
    char buf[buffer.size()];
    for (int i = 0; i < buffer.size(); i++){
        buf[i] = buffer[i];
    }
    XMLDocument doc;
    doc.Parse(buf);

    XMLElement *eventIter = doc.FirstChildElement()->FirstChildElement();
    
    
    unsigned int currentHandle = 0;
    
    while (eventIter != NULL)
    {
        XMLNode *unitIter = eventIter->FirstChildElement()->NextSiblingElement();
        std::string eventName = eventIter->FirstChildElement()->GetText();
        
        while (unitIter != NULL) {
            AudioResource unit;
            
            unit.filename = unitIter->FirstChildElement("filename")->GetText();// first_node("filename")->value();
            printf("filename: %s\n", unit.filename.c_str());
            unit.panning = atof(unitIter->FirstChildElement("panning")->GetText());
            unit.pitch = atof(unitIter->FirstChildElement("pitch")->GetText());
            unit.looping = atoi(unitIter->FirstChildElement("looping")->GetText());
            unit.gain = atof(unitIter->FirstChildElement("gain")->GetText());
            unit.bufferHandle = -1;
            unit.sourceHandle = -1;
            if ( eventName == "apply_force_left" || eventName == "apply_force_right" || eventName=="fall_off") unit.canStop = false;
            else unit.canStop = true;
            alGenSources(1, &unit.sourceHandle);
            resources[eventName].push_back(unit);
            
            unitIter = unitIter->NextSibling();
        }
        
        eventIter = eventIter->NextSiblingElement();
    }
    return true;
}
开发者ID:OneGameAMonth,项目名称:1GAM-Jan-HaikuRacer,代码行数:54,代码来源:AudioResourceManager.cpp

示例5: parseConfiguration

void BirdConfiguration::parseConfiguration(string number) {
	using namespace tinyxml2;
	XMLDocument configurationDoc;
	configurationDoc.LoadFile(file_path.c_str());
	XMLElement* element;
	XMLNode* node;
	XMLNode* rootNode = configurationDoc.FirstChild();
	node=rootNode;

	(*this)["Predator"] = "false";
	(*this)["Number"] = number;

	element = node->FirstChildElement();
	string elm_str;
	while(element){
		elm_str =element->GetText();

		elm_str.erase(std::remove_if(elm_str.begin(),
				elm_str.end(),
				[](char x){return isspace(x);}),
				elm_str.end());

		(*this)[element->Name()] = elm_str;
		element=element->NextSiblingElement();
	}
}
开发者ID:rhidayats,项目名称:Acciadri,代码行数:26,代码来源:BirdConfiguration.cpp

示例6: data

model::describe_snapshots_response::describe_snapshots_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!=NULL)
	{
		request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing Request ID from XML describe_snapshots_response\n";
	XMLElement *ListElement = Element->FirstChildElement("item");
	XMLElement *SnapshotElement;
	string status, snapshot_id,  start_time, volume_id;
	float volume_size;
	while(ListElement != NULL)
	{
		SnapshotElement = ListElement->FirstChildElement("status");
		if(SnapshotElement!=NULL)
		{
			status = SnapshotElement->GetText();
			SnapshotElement = SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing status from XML describe_snapshots_response\n";

		if(SnapshotElement!=NULL)
		{	
			snapshot_id = SnapshotElement->GetText();
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing snapshot_id from XML describe_snapshots_response\n";

		if(SnapshotElement!=NULL)
		{
			SnapshotElement->QueryFloatText(&volume_size);
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing volume_size from XML describe_snapshots_response\n";
		
		if(SnapshotElement!=NULL)
		{
			volume_id=SnapshotElement->GetText();
			SnapshotElement=SnapshotElement->NextSiblingElement();
		}
		else cout<<"Error Parsing volume_id from XML describe_snapshots_response\n";
		
		if(SnapshotElement!=NULL)
			if(SnapshotElement->GetText()!=NULL) start_time = SnapshotElement->GetText();
		else cout<<"Error Parsing start_time from XML describe_snapshots_response\n";
		//add to map
		model::snapshot data(status,snapshot_id,volume_size,volume_id,start_time);
		snapshot_set.push_back(data);
		ListElement=ListElement->NextSiblingElement();
	}

}
开发者ID:sumanswaroop,项目名称:jcs_cpp_sdk,代码行数:58,代码来源:describe_snapshots_response.cpp

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

示例8: getStringXMLAttribute

	DatabaseRule::DatabaseRule( XMLNode* ruleNode )
		: m_ruleScore( 0 )
	{
		m_ruleName = getStringXMLAttribute( ruleNode, "name", "noRule" );
		XMLNode* criteriaListNode = ruleNode->FirstChildElement( "Criteria" );
		for( XMLNode* criteriaNode = criteriaListNode->FirstChildElement( "Criterion" ); criteriaNode; criteriaNode = criteriaNode->NextSiblingElement("Criterion") )
		{
			addCriteria( criteriaNode );
		}
		XMLNode* responseNode = ruleNode->FirstChildElement( "Response" );
		m_responseName = getStringXMLAttribute( responseNode, "name", "noname" );
	}
开发者ID:Zanyruki,项目名称:GameEngine,代码行数:12,代码来源:DatabaseRule.cpp

示例9: loadScores

//read high scores XML ===============================
std::string loadScores ( int player )
{
	int counter=0;
	XMLDocument* doc = new XMLDocument();
	doc->LoadFile ( "highscore.xml" );
	int errorID = doc->ErrorID();
	std::string err = doc->ErrorName();
	std::string playerString[20][3];
	XMLPrinter printer;
	//std::cout << "Test file loaded. ErrorID = "<<errorID<<" "<<err<<std::endl;
	if ( errorID!=0 )
		return "";
	XMLNode* root = doc->FirstChildElement ( "players" );
	if ( root == NULL ) {
		std::cout<<"error xml root"<<std::endl;
		return "";
	}
	XMLElement* node = root->FirstChildElement ( "player" )->ToElement();
	if ( node == NULL ) {
		std::cout<<"error xml"<<std::endl;
		return "";
	}
	while ( node->NextSiblingElement() !=NULL && counter<=player ) {
		XMLElement* element = node->FirstChildElement ( "name" )->ToElement();
		if ( element == NULL ) {
			std::cout<<"error xml"<<std::endl;
			return "";
		}
		playerString[counter][0] = element->GetText();
		//std::cout <<"playerstring="<<playerString[counter][0]<<std::endl;
		element = element->NextSiblingElement ( "score" )->ToElement();
		if ( element == NULL ) {
			std::cout<<"error xml"<<std::endl;
			return "";
		}
		playerString[counter][1] = element->GetText();
		element = element->NextSiblingElement ( "mode" )->ToElement();
		if ( element == NULL ) {
			std::cout<<"error xml"<<std::endl;
			return "";
		}
		playerString[counter][2] = element->GetText();
		node = node->NextSiblingElement ( "player" )->ToElement();
		if ( node == NULL ) {
			std::cout<<"error xml"<<std::endl;
			return "";
		}
		counter++;
	}
	return playerString[player][0]+", "+playerString[player][1]+", "
		+playerString[player][2];
}
开发者ID:upstream335,项目名称:upstream2,代码行数:53,代码来源:johnH.cpp

示例10: cargarNombreMundos

void PanelMundo::cargarNombreMundos() {
	/* En el directorio donde se encuentra el ejecutable, se almacenará un
	 * archivo donde se encuentran todos los mundos que ha creado el diseñador.
	 * Ese archivo se llamará "mundos.xml"
	 */
	XMLDocument doc;
	bool seAbrio = doc.LoadFile(pathFileMundos);
	// Si el archivo no existe, lo creo y salgo sin cargar mundos
	if (!seAbrio) {
		this->crearArchivoMundos();
		return;
	}

	// Obtengo el nodo raiz
	XMLNode* root = doc.RootElement();
	// Si es nulo, salgo sin realizar nada
	if (root == 0)
		return;

	// Obtengo el primer nodo del mundo
	const XMLNode* nodoMundo = root->FirstChildElement("Mundo");
	// Mientras el nodo de mundo no es nulo, cargo los mundos.
	while (nodoMundo != 0) {
		// Obtengo el nodo con el nombre del Mundo.
		const XMLNode* nodoNombre = nodoMundo->FirstChildElement("Nombre");
		std::string nombreMundo = nodoNombre->GetText();
		// Obtengo el atributo de la cantidad de jugadores
		int cantJugadores;
		const char* aCJ = nodoMundo->Attribute("cantJugadores", &cantJugadores);
		if (aCJ != 0) {
			std::string sCantJug = cfd::intToString(cantJugadores);
			nombreMundo += " (" + sCantJug;
			// Si la cantidad de jugadores es 1
			if (cantJugadores == 1) {
				nombreMundo += " jugador)";
			} else {
				nombreMundo += " jugadores)";
			}
		}
		// Obtengo el nodo con la ruta de archivo del mundo.
		const XMLNode* nodoRuta = nodoMundo->FirstChildElement("Ruta");
		// Si los nodos no son nulos, cargo el mundo a la tabla
		if ((nodoNombre != 0) && (nodoRuta != 0)) {
			nombreMundos[nombreMundo] = nodoRuta->GetText();
		}
		// Obtengo el siguiente nodo Mundo
		nodoMundo = nodoMundo->NextSiblingElement("Mundo");
	}
}
开发者ID:ezeperez26,项目名称:cerditosfuriosos,代码行数:49,代码来源:PanelMundo.cpp

示例11: parseDoc

int parseDoc()
{
	XMLNode * root = doc.FirstChild();
	if(root == nullptr)
	{
		return XML_ERROR_FILE_READ_ERROR;
	}
	XMLElement * tuixml = root->FirstChildElement("tuixml");
	if(tuixml == nullptr)
	{
		return XML_ERROR_PARSING_ELEMENT;
	}
	XMLElement * temp = tuixml->FirstChildElement();
	layers.push_back(layer);
	createElementLayers(temp);
}
开发者ID:chenshuiluke,项目名称:terminal_commander,代码行数:16,代码来源:terminal_commander.cpp

示例12: parseLevel

Level* LevelParser::parseLevel(const char* levelFile)
{
	// create a TinyXML document and load the XML level
	XMLDocument xmlDoc;
	if (xmlDoc.LoadFile(levelFile) != XML_SUCCESS)
	{
		std::cout << "Error: unable to load " << levelFile << std::endl;
		return nullptr;
	}

	// create the level object
	Level* pLevel = new Level();

	// get the root node
	XMLNode* pRoot = xmlDoc.RootElement();

	pRoot->ToElement()->QueryAttribute("tilewidth", &m_tileSize);
	pRoot->ToElement()->QueryAttribute("width", &m_width);
	pRoot->ToElement()->QueryAttribute("height", &m_height);
	pLevel->m_width = m_width;
	pLevel->m_height = m_height;
	pLevel->m_tileSize = m_tileSize;
	// Attribute() returns null if not found and std::string cannot be initialized with nullptr.
	const char* musicID = nullptr;
	musicID = pRoot->ToElement()->Attribute("musicID");
	if (musicID == nullptr) musicID = "";
	pLevel->setMusic(musicID);

	// parse object and tile layers
	for (XMLElement* e = pRoot->FirstChildElement(); e != NULL; e = e->NextSiblingElement())
	{
		if (e->Value() == std::string("objectgroup"))
		{
			parseObjLayer(e, pLevel);
		}
		else if (e->Value() == std::string("layer"))
		{
			parseTileLayer(e, pLevel);
		}
		else if (e->Value() == std::string("background"))
		{
			parseBckLayer(e, pLevel);
		}
	}

	return pLevel;
}
开发者ID:afrosistema,项目名称:S2PEditor,代码行数:47,代码来源:LevelParser.cpp

示例13:

model::delete_snapshot_response::delete_snapshot_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!=NULL)
	{	if(Element->GetText()!=NULL)request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing request_id from XML delete_snapshot_response\n";
	
	if(Element!=NULL)
		Element->QueryBoolText(&result);
	else cout<<"Error Parsing result from XML delete_snapshot_response\n";
}	
开发者ID:devendermishrajio,项目名称:jcs_cpp_sdk,代码行数:17,代码来源:delete_snapshot_response.cpp

示例14: ParseStatus

void Response::ParseStatus()
{
  int errorCode;
  std::string errorDescription;

  XMLNode *rootElement = m_document->RootElement();
  XMLElement *statusElement = rootElement->FirstChildElement(GetStatusElementName().c_str());

  // Not all response types always return the status element
  if (statusElement)
  {
    errorCode = xmltv::Utilities::QueryIntText(statusElement->FirstChildElement("ErrorCode"));
    errorDescription = statusElement->FirstChildElement("ErrorDescription")->GetText();

    m_error.code = static_cast<ErrorCode>(errorCode);
    m_error.description = errorDescription;
  }
}
开发者ID:janbar,项目名称:pvr.vbox,代码行数:18,代码来源:Response.cpp

示例15: data

model::describe_instance_types_response::describe_instance_types_response(const string &xml_doc)
{
	XMLDocument doc;
	doc.Parse(xml_doc.c_str());
	//Root
	XMLNode *RootNode = doc.FirstChild();
	XMLElement *Element = RootNode->FirstChildElement("requestId");
	if(Element!=NULL)
	{
		if(Element->GetText()!=NULL) request_id = Element->GetText();
		Element=Element->NextSiblingElement();
	}
	else cout<<"Error Parsing request_id from XML describe_instance_types_response\n";
	
	XMLElement *InstanceTypeElement,*ListElement = Element->FirstChildElement("item");
	float vcpus,ram;
	string id;
	while(ListElement != NULL)
	{
		InstanceTypeElement = ListElement->FirstChildElement("vcpus");
		if(InstanceTypeElement!=NULL)
		{
			InstanceTypeElement->QueryFloatText(&vcpus);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing VCPUS from XML describe_instance_types_response\n";
		if(InstanceTypeElement!=NULL)
		{	
			InstanceTypeElement->QueryFloatText(&ram);
			InstanceTypeElement = InstanceTypeElement->NextSiblingElement();
		}
		else cout<<"Error Parsing RAM data from XML describe_instance_types_response\n";

		if(InstanceTypeElement!=NULL)
			{if(InstanceTypeElement->GetText() != NULL)id = InstanceTypeElement->GetText();}
		else cout<<"Error Parsing instance_id from XML describe_instance_types_response\n";
		//Add to map
		model::instance_type data(vcpus, ram, id);
		instance_type_set.push_back(data);

		ListElement=ListElement->NextSiblingElement();
	}
}
开发者ID:devendermishrajio,项目名称:jcs_cpp_sdk,代码行数:43,代码来源:describe_instance_types_response.cpp


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