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


C++ TiXmlElement::FirstAttribute方法代码示例

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


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

示例1: dumpXML

bool dumpXML(string& fname)
{
    try {
        TiXmlDocument* doc = new TiXmlDocument (fname.c_str());
        doc->LoadFile ();
        TiXmlElement* root = doc->RootElement ();
        
        cout << root->Value () << endl;

        TiXmlElement* version = root->FirstChildElement ();
        TiXmlAttribute* atti_major = version->FirstAttribute ();
        TiXmlAttribute* atti_minor = version->LastAttribute ();

        TiXmlElement* file = version->FirstChildElement ();
        TiXmlAttribute* atti_size = file->FirstAttribute ();
        TiXmlAttribute* atti_date = file->LastAttribute ();

        cout << version->FirstChild ()->Value() << endl;
        cout << atti_major->Name () << ": " << atti_major->Value () << ", " <<
        atti_minor->Name () << ": " << atti_minor->Value () << endl;
        cout << file->FirstChild ()->Value() << endl;
        cout << atti_size->Name () << ": " << atti_size->Value () << ", " << \
        atti_date->Name () << ": " << atti_date->Value () << endl;

    }
    catch (string& e) {
        return (false);
    }

    return true;
}
开发者ID:aeihu,项目名称:hacks,代码行数:31,代码来源:main.cpp

示例2: Load

void CharacterLoader::Load(TiXmlDocument& doc)
{
	TiXmlElement* root = doc.FirstChildElement("Body");
	root = root->FirstChildElement("Character");
	while (root)
	{
		TiXmlAttribute* attribute = root->FirstAttribute();
		std::string str = attribute->Name();
		if (str == "name")
		{
			std::string characterName = attribute->Value();
			std::string fileName;
			int x1 = -1, x2 = -1, y1 = -1, y2 = -1;
			TiXmlElement* element = root->FirstChildElement("a");
			
			while (element)
			{
				TiXmlAttribute* attrib = element->FirstAttribute();
				while (attrib)
				{
					std::string name = attrib->Name();
					std::string value = attrib->Value();
					addValue(characterName, name, value);

					attrib = attrib->Next();
				}
				element = element->NextSiblingElement("a");
			}

		}

		root = root->NextSiblingElement("Character");
	}
}
开发者ID:zsebastian,项目名称:Floof,代码行数:34,代码来源:CharacterLoader.cpp

示例3: Load

void ImageLoader::Load(TiXmlDocument& doc)
{
	TiXmlElement* root = doc.FirstChildElement("Body");
	root = root->FirstChildElement("Image");
	while (root)
	{
		TiXmlAttribute* attribute = root->FirstAttribute();
		std::string str = attribute->Name();
		if (str == "name")
		{
			std::string imageName = attribute->Value();
			std::string fileName;
			int x1 = -1, x2 = -1, y1 = -1, y2 = -1;
			TiXmlElement* element = root->FirstChildElement("a");
			if (element)
			{
				if (element->Attribute("file"))
				{
					fileName = element->Attribute("file");
				}
			}

			element = root->FirstChildElement("rect");

			while (element)
			{

				TiXmlAttribute* attrib = element->FirstAttribute();
				while (attrib)
				{
					std::string name = attrib->Name();
					if (name == "x1")
					{
						x1 = attrib->IntValue();
					}
					else if (name == "x2")
					{
						x2 = attrib->IntValue();
					}
					else if (name == "y1")
					{
						y1 = attrib->IntValue();
					}
					else if (name == "y2")
					{
						y2 = attrib->IntValue();
					}

					attrib = attrib->Next();
				}
				element = element->NextSiblingElement("rect");
			}

			internalCreate(imageName, fileName, x1, y1, x2, y2);
		}

		root = root->NextSiblingElement("Image");
	}
}
开发者ID:zsebastian,项目名称:Floof,代码行数:59,代码来源:ImageLoader.cpp

示例4: RebuildXrcFile

bool wxsItemResData::RebuildXrcFile()
{
    // First - opening file
    TiXmlDocument Doc;
    TiXmlElement* Resources = nullptr;
    TiXmlElement* Object = nullptr;

    if ( TinyXML::LoadDocument(m_XrcFileName,&Doc) )
    {
        Resources = Doc.FirstChildElement("resource");
    }

    if ( !Resources )
    {
        Doc.Clear();
        Doc.InsertEndChild(TiXmlDeclaration("1.0","utf-8",""));
        Resources = Doc.InsertEndChild(TiXmlElement("resource"))->ToElement();
        Resources->SetAttribute("xmlns","http://www.wxwidgets.org/wxxrc");
    }

    // Searching for object representing this resource
    for ( Object = Resources->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
    {
        if ( cbC2U(Object->Attribute("name")) == m_ClassName )
        {
            Object->Clear();
            while ( Object->FirstAttribute() )
            {
                Object->RemoveAttribute(Object->FirstAttribute()->Name());
            }
            break;
        }
    }

    if ( !Object )
    {
        Object = Resources->InsertEndChild(TiXmlElement("object"))->ToElement();
    }

    // The only things left are: to dump item into object ...
    m_RootItem->XmlWrite(Object,true,false);
    Object->SetAttribute("name",cbU2C(m_ClassName));
    for ( int i=0; i<GetToolsCount(); i++ )
    {
        TiXmlElement* ToolElement = Object->InsertEndChild(TiXmlElement("object"))->ToElement();
        m_Tools[i]->XmlWrite(ToolElement,true,false);
    }

    // ... and save back the file
    return TinyXML::SaveDocument(m_XrcFileName,&Doc);
}
开发者ID:WinterMute,项目名称:codeblocks_sf,代码行数:51,代码来源:wxsitemresdata.cpp

示例5: CompileAnimations

void MeshCompiler::CompileAnimations( TiXmlElement* Arm )
{
	// Get named animations from the keyframes
	for( TiXmlElement* Keyf = Arm->FirstChildElement( "anim" ); Keyf; Keyf = Keyf->NextSiblingElement( "anim" ) )
	{
		Animation Animation;

		// Get starting frame and name (patch up lengths later)
		TiXmlAttribute* KeyfAttr = Keyf->FirstAttribute();
		Animation.m_StartFrame = (uint16)KeyfAttr->IntValue();

		KeyfAttr = KeyfAttr->Next();
		const char* pName = KeyfAttr->Value();
		CleanStrncpy( Animation.m_Name, pName, ANIM_NAME_LENGTH );
		Animation.m_HashedName = Animation.m_Name;

		m_Animations.PushBack( Animation );
		++m_Header.m_NumAnims;
	}
	for( int i = 0; i < ( m_Header.m_NumAnims - 1 ); ++i )
	{
		Animation& ThisAnim = m_Animations[ i ];
		Animation& NextAnim = m_Animations[ i + 1 ];
		ThisAnim.m_Length = NextAnim.m_StartFrame - ThisAnim.m_StartFrame;
	}
	// Patch up the last animation's length separately
	if( m_Header.m_NumAnims )
	{
		Animation& ThisAnim = m_Animations[ m_Header.m_NumAnims - 1 ];
		ThisAnim.m_Length = (uint16)( ( m_Header.m_NumFrames ) - ThisAnim.m_StartFrame );	// -1 because of added T-pose
	}
}
开发者ID:MinorKeyGames,项目名称:Eldritch,代码行数:32,代码来源:meshcompiler.cpp

示例6:

BaseModule * XmlConfigurationLoader::LoadModule(void * module){
	TiXmlElement * elem = (TiXmlElement * )module;
	TiXmlAttribute * attr = elem->FirstAttribute();
	if(attr == 0){
		return 0;
	}
	map<string, string> parameters_map;
	while(attr){
		
		parameters_map.insert(	pair<string,string>(
									string(attr->Name()),
									string(attr->Value())
								)		
							);
		attr = attr->Next();
	}

	BaseModule * loaded_module = mDl->LoadModuleFrom(parameters_map[string("src")]);
	if (loaded_module != 0){
		for (map<string, string>::iterator it = parameters_map.begin();
			it != parameters_map.end();
			it++){
			loaded_module->AddAttribute(it->first, it->second);
		}
	}
	return loaded_module;
}
开发者ID:lomelina,项目名称:Biosandbox,代码行数:27,代码来源:XmlConfigurationLoader.cpp

示例7: xml_ModifyNode_Attribute

/*!
*  /brief 修改指定节点的属性值。
*
*  /param XmlFile xml文件全路径。
*  /param strNodeName 指定的节点名。
*  /param AttMap 重新设定的属性值,这是一个map,前一个为属性名,后一个为属性值
*  /return 是否成功。true为成功,false表示失败。
*/
bool xml_ModifyNode_Attribute(TiXmlElement *pRootEle, std::string strNodeName,
        std::map<std::string, std::string> &AttMap)
{
    typedef std::pair<std::string, std::string> String_Pair;
    if (NULL == pRootEle) {
        return false;
    }

    TiXmlElement *pNode = NULL;
    xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
    if (NULL != pNode) {
        TiXmlAttribute* pAttr = NULL;
        std::string strAttName;
        for (pAttr = pNode->FirstAttribute(); pAttr; pAttr = pAttr->Next()) {
            strAttName = pAttr->Name();
            std::map<std::string, std::string>::iterator iter;
            for (iter = AttMap.begin(); iter != AttMap.end(); iter++) {
                if (strAttName == iter->first) {
                    pAttr->SetValue(iter->second);
                }
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:ubuntu-chu,项目名称:commu_manager,代码行数:35,代码来源:parse.cpp

示例8: UIModify

void CALLBACK CUICommandHistory::UIModify(TiXmlNode* pNode)
{
	TiXmlElement* pElement = pNode->ToElement();
	CStringA strName = pElement->Attribute("myname");
	pElement->RemoveAttribute("myname");
	if(strName.IsEmpty())
		return;

	CPaintManagerUI* pManager = g_pMainFrame->GetActiveUIView()->GetPaintManager();
	CControlUI* pControl = pManager->FindControl(StringConvertor::Utf8ToWide(strName));
	TiXmlAttribute* pAttrib = pElement->FirstAttribute();
	if(pControl == NULL)
		return;

	while(pAttrib)
	{
		if(strcmp(pAttrib->Name(), "name") == 0)
		{
			pManager->ReapObjects(pControl);
			g_pClassView->RenameUITreeItem(pControl, StringConvertor::Utf8ToWide(pAttrib->Value()));
			pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name())
				, StringConvertor::Utf8ToWide(pAttrib->Value()));
			pManager->InitControls(pControl);
		}
		else
			pControl->SetAttribute(StringConvertor::Utf8ToWide(pAttrib->Name())
				, StringConvertor::Utf8ToWide(pAttrib->Value()));

		pAttrib = pAttrib->Next();
	}
	CControlUI* pParent = pControl->GetParent();
	if(pParent == NULL)
		pParent = pControl;
	pParent->SetPos(pParent->GetPos());
}
开发者ID:DayDayUpCQ,项目名称:misc,代码行数:35,代码来源:UICommandHistory.cpp

示例9: parseTinyXmlFile

void HelloWorld::parseTinyXmlFile()
{
	try
	{
		char filePath[1024]= {'\0'};
		memset(filePath,0,sizeof(filePath));
		strcat(filePath,CCFileUtils::sharedFileUtils()->getWriteablePath().c_str());
		strcat(filePath,"CreatedTinyXml.xml");

		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument(filePath);
		myDocument->LoadFile();
		//获得根元素,即Persons。
		TiXmlElement *RootElement = myDocument->RootElement();
		//输出根元素名称,即输出Persons。
		CCLOG(RootElement->Value());
		//获得第一个Person节点。
		TiXmlElement *FirstPerson = RootElement->FirstChildElement();
		//获得第一个Person的name节点和age节点和ID属性。
		TiXmlElement *NameElement = FirstPerson->FirstChildElement();
		TiXmlElement *AgeElement = NameElement->NextSiblingElement();
		TiXmlAttribute *IDAttribute = FirstPerson->FirstAttribute();
		//输出第一个Person的name内容,即周星星;age内容,即;ID属性,即。

		CCLOG(NameElement->FirstChild()->Value());
		CCLOG(AgeElement->FirstChild()->Value());
		CCLOG(IDAttribute->Value());
	}
	catch (string& e)
	{
		return ;
	}
	return ;
}
开发者ID:YarinYang,项目名称:cocos2d-x-test,代码行数:34,代码来源:HelloWorldScene.cpp

示例10: loadFromXML

/**
* 从xml文件中读取“键-值”对 load "key-value" from xml file
* @param filename 读取的xml文件,必须是按照规定的格式
* @return 布尔值 读取成功与否
*/
bool Properties::loadFromXML(const string filename)
{
	TiXmlDocument doc(filename.c_str());
	bool loadOkay = doc.LoadFile();//以utf-8格式读取xml文件
	if (!loadOkay)
	{
		return false;
	}
	TiXmlNode *node = doc.FirstChild("properties");
        #ifdef DEBUG_PROPERTIES_H
	node->Print(stdout, 1);
	cout << endl;
        #endif
	TiXmlElement* propertiesElement = node->ToElement();
	for(TiXmlElement *it = propertiesElement->FirstChildElement("entry")
		; it!=NULL ;
		it = it->NextSiblingElement("entry")
		)
	{
		TiXmlAttribute *att = it->FirstAttribute();
		this->setProperty(att->Value(), it->GetText());
		#ifdef DEBUG_PROPERTIES_H
		cout << "[" << att->Name() << ":" << att->Value() << "->" << it->GetText() << "]" << endl;
                #endif
	}
	return true;
}
开发者ID:shlice,项目名称:libproperties,代码行数:32,代码来源:libproperties.cpp

示例11: DecodeLeaf

void xmlLeafLoad::DecodeLeaf( TiXmlElement* root )
{
	//извлечь данные о листве

	//извлечение информации из узла XML
	TiXmlNode* node = root->FirstChild( m_LeafNames.m_sLeaf.c_str() );

	if ( node )
	{
		TiXmlElement* pLeaf = node->ToElement();

		//извлечь имя элемента
		const char *_name = pLeaf->Value();
		std::string _sElem( _name );

		//получить указатель на первый атрибут элемента
		TiXmlAttribute* _attr = pLeaf->FirstAttribute();

		//извлечь данные о текстурах
		DecodeTextures( pLeaf );

		//извлечь данные о влиянии ветра
		DecodeWind( pLeaf );

		//декодировать данные LOD'ов
		DecodeLODs( pLeaf );
	}
}
开发者ID:wangfeilong321,项目名称:osgtraining,代码行数:28,代码来源:xmlLeafLoad.cpp

示例12: ReadXmlFile

bool ReadXmlFile(std::string& szFileName)
{//读取Xml文件,并遍历
	try
	{
		std::string fullPath = GetAppPath();
		fullPath += "\\";
		fullPath += szFileName;
		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument(fullPath.c_str());
		myDocument->LoadFile();
		//获得根元素,即Persons。
		TiXmlElement *RootElement = myDocument->RootElement();
		//输出根元素名称,即输出Persons。
		std::cout << RootElement->Value() << std::endl;
		//获得第一个Person节点。
		TiXmlElement *FirstPerson = RootElement->FirstChildElement();
		//获得第一个Person的name节点和age节点和ID属性。
		TiXmlElement *NameElement = FirstPerson->FirstChildElement();
		TiXmlElement *AgeElement = NameElement->NextSiblingElement();
		TiXmlAttribute *IDAttribute = FirstPerson->FirstAttribute();
		//输出第一个Person的name内容,即周星星;age内容,即;ID属性,即。
		std::cout << NameElement->FirstChild()->Value() << std::endl;
		std::cout << AgeElement->FirstChild()->Value() << std::endl;
		std::cout << IDAttribute->Value()<< std::endl;
	}
	catch (std::string& e)
	{
		return false;
	}
	return true;
}
开发者ID:TaChiBaNaIChiKa,项目名称:repo1,代码行数:31,代码来源:xmlTree.cpp

示例13: main

int main()  
{  
    //创建一个XML的文档对象。  
    TiXmlDocument *myDocument = new TiXmlDocument("test.xml");  
    myDocument->LoadFile();  
      
    //获得根元素,即Persons。  
    TiXmlElement *RootElement = myDocument->RootElement();  
  
    //输出根元素名称,即输出Persons。  
    cout << RootElement->Value() << endl;  
      
    //获得第一个Person节点。  
    TiXmlElement *FirstPerson = RootElement->FirstChildElement();  
    //输出接点名Person  
  
    cout << FirstPerson->Value() << endl;  
    //获得第一个Person的name节点和age节点和ID属性。  
    TiXmlElement *NameElement = FirstPerson->FirstChildElement();  
    TiXmlElement *AgeElement = NameElement->NextSiblingElement();  
    TiXmlElement *SexElement = AgeElement->NextSiblingElement();  
    TiXmlAttribute *IDAttribute = FirstPerson->FirstAttribute();  
      
    //输出第一个Person的name内容,即周星星;age内容,即20;ID属性,即1。  
    cout << NameElement->FirstChild()->Value() << endl;  
    cout << AgeElement->FirstChild()->Value() << endl;  
    cout << SexElement->FirstChild()->Value() << endl; 
    cout << IDAttribute->Value() << endl;  
  
    return 0;  
} 
开发者ID:chenhuidong,项目名称:MyGit,代码行数:31,代码来源:TestTinyXml.cpp

示例14: DecodeLODs

void xmlLeafLoad::DecodeLODs( TiXmlElement* root )
{
	//декодировать данные LOD'ов

	//извлечение информации из узла XML
	TiXmlNode* node = root->FirstChild( m_LeafNames.m_sLODs.c_str() );

	if ( node )
	{
		TiXmlElement* pLODs = node->ToElement();

		//извлечь имя элемента
		const char *_name = pLODs->Value();
		std::string _sElem( _name );

		//получить указатель на первый атрибут элемента
		TiXmlAttribute* _attr = pLODs->FirstAttribute();

		//узнать количество LOD'ов
		DecodeAttrNumLods( _attr );

		//декодировать данные LOD'а
		DecodeLOD( pLODs );
	}
}
开发者ID:wangfeilong321,项目名称:osgtraining,代码行数:25,代码来源:xmlLeafLoad.cpp

示例15: LoadScriptSearchPathXml

void CBaseScriptApp::LoadScriptSearchPathXml()
{
	CXmlConfig*		pXmlSearchDir	= LoadCfgFile( "etc/common/SearchDir.xml", "search_dir" );

	TiXmlNode*		pLoadPath = pXmlSearchDir->Get<TiXmlElement*>("load_path");

	const wchar_t* szRootPath = m_pRootPathMgr->GetRootPath();

	TiXmlNode* pNode = pLoadPath->FirstChild("path"); 
	while(pNode)
	{
		TiXmlElement* pElement = pNode->ToElement();
		if (pElement)
		{
			TiXmlAttribute* attribute = pElement->FirstAttribute();
			AddScriptLoadPath(attribute->Value(), pElement->GetText());
			wstring alias = utf8_to_utf16(attribute->Value());
			CPkgFile::AddLoadPath(alias.c_str(), szRootPath);
		}
		pNode = pNode->NextSibling();

	}
	
	SafeDelete(pXmlSearchDir);		
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:25,代码来源:CBaseScriptApp.cpp


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