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


C++ TiXmlDocument::FirstChild方法代码示例

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


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

示例1: AddUserInfoToCrashDescriptorXML

void CMainDlg::AddUserInfoToCrashDescriptorXML(CString sEmail, CString sDesc)
{ 
  strconv_t strconv;

  TiXmlDocument doc;
  
  CString sFileName = g_CrashInfo.m_sErrorReportDirName + _T("\\crashrpt.xml");
  bool bLoad = doc.LoadFile(strconv.t2a(sFileName.GetBuffer(0)));
  if(!bLoad)
    return;

  TiXmlNode* root = doc.FirstChild("CrashRpt");
  if(!root)
    return;

  // Write user e-mail

  TiXmlElement* email = new TiXmlElement("UserEmail");
  root->LinkEndChild(email);

  LPCSTR lpszEmail = strconv.t2a(sEmail.GetBuffer(0));
  TiXmlText* email_text = new TiXmlText(lpszEmail);
  email->LinkEndChild(email_text);              

  // Write problem description

  TiXmlElement* desc = new TiXmlElement("ProblemDescription");
  root->LinkEndChild(desc);

  LPCSTR lpszDesc = strconv.t2a(sDesc.GetBuffer(0));
  TiXmlText* desc_text = new TiXmlText(lpszDesc);
  desc->LinkEndChild(desc_text);              

  doc.SaveFile();        
}
开发者ID:doo,项目名称:CrashRpt,代码行数:35,代码来源:MainDlg.cpp

示例2: getDocument

//************************************
// Method:    GetDocument
// FullName:  vtPhysics::pFactory::GetDocument
// Access:    public 
// Returns:   TiXmlDocument*
// Qualifier:
// Parameter: XString filename
//************************************
TiXmlDocument* pFactory::getDocument(XString filename)
{
	

	XString fname(filename.Str());
	if ( fname.Length() )
	{
		XString fnameTest = ResolveFileName(fname.CStr());
		if ( fnameTest.Length())
		{
			TiXmlDocument* result  = new TiXmlDocument(fnameTest.Str());
			result->LoadFile(fnameTest.Str());
			result->Parse(fnameTest.Str());

			TiXmlNode* node = result->FirstChild( "vtPhysics" );
			if (!node)
			{
				GetPMan()->m_Context->OutputToConsoleEx("PFactory : Couldn't load Document : %s",filename.Str());
				return NULL;
			}else
			{
				return result;
			}
		}
	}
	return NULL;
}
开发者ID:gbaumgart,项目名称:vt,代码行数:35,代码来源:pFactoryXML.cpp

示例3: GetBkgPingCheckOpt

BOOL GetBkgPingCheckOpt(PBBS_BKG_PINGCHECK_OPT pPingOpt)
{
	TiXmlDocument doc;
	const char *pszCustomDest = NULL;
	bool bOperating = false;
	int nBreakInt = 0;
	int nPingInt = 0;
	int nMaxCount = 0;

	if( CheckValidXML(&doc) == FALSE )
	{
		return FALSE;
	}

	TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("BkgPingCheck");


	pElem->QueryBoolAttribute("Operating", &bOperating);
	pElem->QueryIntAttribute("BreakInterval",  &nBreakInt);
	pElem->QueryIntAttribute("PingInterval", &nPingInt);
	pElem->QueryIntAttribute("MaxCheckCnt", &nMaxCount);
	pszCustomDest = pElem->Attribute("CustomDestAddr");


	pPingOpt->bOperating = bOperating;
	pPingOpt->dwBreakInterval = nBreakInt;
	pPingOpt->dwPingInterval = nPingInt;
	pPingOpt->dwMaxCheckCount = nMaxCount;

	mbstowcs(pPingOpt->tszCustomDestAddr, pszCustomDest, strlen(pszCustomDest));

	return TRUE;
}
开发者ID:NemProjects,项目名称:WLAN,代码行数:33,代码来源:BBS_WifiXml.cpp

示例4: processNotify

void SipRedirectorPrivateStorageJoin::processNotify(const char* body)
{
   // Initialize Tiny XML document object.
   TiXmlDocument document;
   TiXmlNode* dialog_info;
   if (
      // Load the XML into it.
      document.Parse(body) &&
      // Find the top element, which should be a <dialog-info>.
      (dialog_info = document.FirstChild("dialog-info")) != NULL &&
      dialog_info->Type() == TiXmlNode::ELEMENT)
   {
      Os::Logger::instance().log(FAC_SIP, PRI_DEBUG,
                    "SipRedirectorPrivateStorageJoin::processNotify "
                    "Body parsed, <dialog-info> found");
      // Find all the <dialog> elements.
      for (TiXmlNode* dialog = 0;
           (dialog = dialog_info->IterateChildren("dialog", dialog)); )
      {
         // Process each <dialog> element.
         processNotifyDialogElement(dialog->ToElement());
      }
   }
   else
   {
      // Report error.
      Os::Logger::instance().log(FAC_SIP, PRI_ERR,
                    "SipRedirectorPrivateStorageJoin::processNotify "
                    "NOTIFY body invalid: '%s'", body);
   }
}
开发者ID:ClydeFroq,项目名称:sipxecs,代码行数:31,代码来源:SipRedirectorJoin.cpp

示例5: loadDialogues

void Stage::loadDialogues(std::string file)
{
    writeLogLine("Loading dialogues from XML.");

    char *archivo=new char[255];
    strcpy(archivo,"stages/");
    strcat(archivo,file.c_str());
    strcat(archivo,"/dialogues.xml");
    TiXmlDocument doc_t( archivo );
    doc_t.LoadFile();
    TiXmlDocument *doc;
    doc=&doc_t;

    TiXmlNode *dialogues_file=doc->FirstChild("DialoguesFile");

    if(dialogues_file==NULL)
        return;

    for(TiXmlNode *dialogue_node=dialogues_file->FirstChild("dialogue");
            dialogue_node!=NULL;
            dialogue_node=dialogue_node->NextSibling("dialogue"))
    {
        int frame=atoi(dialogue_node->ToElement()->Attribute("frame"));
        std::string text=dialogue_node->ToElement()->Attribute("text");
        std::string path=dialogue_node->ToElement()->Attribute("path");

        dialogues[frame]=new Dialogue(painter,sonido,receiver,text,painter->getTexture("stages/"+file+"/"+path));
    }
}
开发者ID:Rosalila,项目名称:STG-Android,代码行数:29,代码来源:Stage.cpp

示例6: loadFromFile

bool LanguageManager::loadFromFile(const char* file)
{
	TiXmlDocument doc;
	doc.LoadFile(file);

#ifdef WIN32 // seemingly unused
	const char* err = doc.ErrorDesc();
#endif

	TiXmlNode *cNode = doc.FirstChild("lang");

	if (!cNode)
		return false;

	auto parseString = [this](TiXmlElement* str)
	{
		const char* name = str->Attribute("name");
		const char* val = str->GetText();

		if (!name || !val)
			return;

		LanguageString* temp = dynamic_cast<LanguageString*>(this->BaseManager::findItem(name));

		if (!temp)
		{
			temp = new LanguageString(name);
			this->addItem( temp );
		}

#ifdef DESURA_OFFICAL_BUILD
		temp->ustr = val;
#else
		std::vector<std::string> res;
		UTIL::STRING::tokenize(gcString(val), res, "Desura");

		gcString out;

		for (size_t x=0; x<res.size(); x++)
		{
			out += res[x];

			if (x+1 != res.size())
				out += PRODUCT_NAME;
		}

		temp->ustr = out;
#endif
	};

	XML::for_each_child("str", cNode->FirstChild("strings"), parseString);

#ifdef WIN32
	XML::for_each_child("str", cNode->FirstChild("windows"), parseString);
#else
	XML::for_each_child("str", cNode->FirstChild("linux"), parseString);
#endif

	return true;
}
开发者ID:harmonise,项目名称:Desurium,代码行数:60,代码来源:LanguageManager.cpp

示例7: main

int main()
{
    TiXmlDocument doc;
    doc.Parse(testXml.c_str());

    TiXmlNode* node = 0;
    TiXmlElement* requestElement = 0;
   
    node = doc.FirstChild("request");
    assert(node);
    requestElement = node->ToElement();
    assert(requestElement);

    string typeInfo(requestElement->Attribute("type"));

    if (typeInfo == "heartbeat")
    {
        cout << "Hey heartbeat" << endl;
        boost::replace_first(testXml,"request type=\"heartbeat\"", "request");
    }
    
    cout << testXml << endl;

    return 0;
}
开发者ID:kevinneu,项目名称:dbdky_cac,代码行数:25,代码来源:main.cpp

示例8: ParseCrashDescription

int CCrashInfoReader::ParseCrashDescription(CString sFileName)
{
  strconv_t strconv;

  TiXmlDocument doc;
  bool bOpen = doc.LoadFile(strconv.t2a(sFileName));
  if(!bOpen)
    return 1;

  TiXmlHandle hRoot = doc.FirstChild("CrashRpt");
  if(hRoot.ToElement()==NULL)
    return 1;

  TiXmlHandle hAppName = hRoot.FirstChild("AppName");
  const char* szAppName = hAppName.FirstChild().ToText()->Value();
  if(szAppName!=NULL)
    m_sAppName = strconv.utf82t(szAppName);

  TiXmlHandle hAppVersion = hRoot.FirstChild("AppVersion");
  const char* szAppVersion = hAppVersion.FirstChild().ToText()->Value();
  if(szAppVersion!=NULL)
    m_sAppVersion = strconv.utf82t(szAppVersion);

  TiXmlHandle hImageName = hRoot.FirstChild("ImageName");
  const char* szImageName = hAppName.FirstChild().ToText()->Value();
  if(szImageName!=NULL)
    m_sImageName = strconv.utf82t(szImageName);

  return 0;
}
开发者ID:doo,项目名称:CrashRpt,代码行数:30,代码来源:CrashInfoReader.cpp

示例9: BMessage

status_t Converter::ConvertFreeMind2PDoc()
{
	BMessage	*document		= new BMessage();
	BMessage	*allNodes		= new BMessage();
	BMessage	*allConnections	= new BMessage();
	char		*xmlString;
	off_t		start,end;
	middel.Set(400,400,600,550);
	in->Seek(0,SEEK_SET);
	start = in->Position();
	in->Seek(0,SEEK_END);
	end = in->Position();
	in->Seek(0,SEEK_SET);
	size_t		size= end-start;
	xmlString=new char[size+1];
	in->Read(xmlString, size);
	TiXmlDocument	doc;
	doc.Parse(xmlString);
	delete xmlString;
	if (doc.Error())
		return B_ERROR;
	else
	{
		TiXmlNode*		node	= NULL;
		TiXmlElement*	element	= NULL;
		node = doc.FirstChild("map");
		node = node->FirstChild("node");
		element	= node->ToElement();
		CreateNode(allNodes, allConnections,element,0,0);
	}
	document->AddMessage("PDocument::allConnections",allConnections);
	document->AddMessage("PDocument::allNodes",allNodes);
	status_t err= document->Flatten(out);
}
开发者ID:BackupTheBerlios,项目名称:projectconcepto-svn,代码行数:34,代码来源:FreeMindTranslator.cpp

示例10: WriteToXml

void WriteToXml(string& strXml, vector<bool>& vecType,string& FileName)
{
	COriFileOperate oriFile(FileName);
	size_t nVecSize = vecType.size();
	if (strXml.find("chinese_simple") != -1)
	{
		for (size_t i=1;i<nVecSize;++i)
		{
			vecType[i] = false;
		}
	}
	char* szNumOrStrInfo = new char[nVecSize+1];
	for (size_t i = 0; i < nVecSize; i++)
	{
		if (vecType[i])
		{
			szNumOrStrInfo[i] = 'n';
		}
		else
		{
			szNumOrStrInfo[i] = 's';
		}
	}
	szNumOrStrInfo[nVecSize] = '\0';
	TiXmlDocument* pXmlDoc = new TiXmlDocument;
	pXmlDoc->InsertEndChild(TiXmlElement("config"));
	TiXmlNode* pXmlNode = pXmlDoc->FirstChild("config");
	pXmlNode->InsertEndChild(TiXmlElement("TableType"));
	TiXmlElement* pXmlElem = pXmlNode->FirstChildElement("TableType");
	pXmlElem->InsertEndChild(TiXmlText("S"));
	string str = szNumOrStrInfo;
	string str1 = oriFile.GetDataByRowCol(0,0);
	transform(str1.begin(),str1.end(),str1.begin(),toupper);
	for(uint32 i=1;i<=str.size();i++)
	{
		TiXmlElement* cxn = new TiXmlElement("Col");
		pXmlNode->LinkEndChild(cxn);
	//	cxn->SetAttribute("ColNum",i);
		if(str1!="NOTE:")
		{
			cxn->SetAttribute("Name",oriFile.GetDataByRowCol(0,i-1).c_str());
		}
		else
		{
			cxn->SetAttribute("Name",oriFile.GetDataByRowCol(1,i-1).c_str());
		}
		string ss;
		stringstream temp;
		temp<<szNumOrStrInfo[i-1];
		temp>>ss;
		cxn->SetAttribute("Type",ss);
	}

	pXmlDoc->SaveFile(strXml);

	delete pXmlDoc;
	pXmlDoc = NULL;
	delete[] szNumOrStrInfo;
	szNumOrStrInfo = NULL;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:60,代码来源:MakeTxtXmlAuto.cpp

示例11: GetPowerOpt

BOOL GetPowerOpt(int *pnAllowSuspendMode)
{
	TiXmlDocument doc;

	int nAllowSuspendMode = 0;
	int nResult = TIXML_NO_ATTRIBUTE;


	if( CheckValidXML(&doc) == FALSE )
	{
		return FALSE;
	}

	TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("PowerOption");

	nResult = pElem->QueryIntAttribute("AllowSuspend",  pnAllowSuspendMode);
	// 초기값이 설정되지 않았을때는, 연결된 상태에서 SuspendMode 허용 기본 설정
	if( nResult == TIXML_WRONG_TYPE )
	{
		*pnAllowSuspendMode = -1;
	}
	else if ( nResult == TIXML_NO_ATTRIBUTE )
	{
		RETAILMSG(1, (TEXT("[PSH] ERROR \r\n") ));
	}

	return TRUE;
}
开发者ID:NemProjects,项目名称:WLAN,代码行数:28,代码来源:BBS_WifiXml.cpp

示例12: Save

bool CArtist::Save(TiXmlNode *node, const CStdString &tag, const CStdString& strPath)
{
  if (!node) return false;

  // we start with a <tag> tag
  TiXmlElement artistElement(tag.c_str());
  TiXmlNode *artist = node->InsertEndChild(artistElement);

  if (!artist) return false;

  XMLUtils::SetString(artist,       "name", strArtist);
  XMLUtils::SetStringArray(artist, "genre", genre);
  XMLUtils::SetStringArray(artist, "style", styles);
  XMLUtils::SetStringArray(artist,  "mood", moods);
  XMLUtils::SetStringArray(artist, "yearsactive", yearsActive);
  XMLUtils::SetStringArray(artist, "instruments", instruments);
  XMLUtils::SetString(artist,        "born", strBorn);
  XMLUtils::SetString(artist,      "formed", strFormed);
  XMLUtils::SetString(artist,   "biography", strBiography);
  XMLUtils::SetString(artist,        "died", strDied);
  XMLUtils::SetString(artist,   "disbanded", strDisbanded);
  if (!thumbURL.m_xml.empty())
  {
    TiXmlDocument doc;
    doc.Parse(thumbURL.m_xml);
    const TiXmlNode* thumb = doc.FirstChild("thumb");
    while (thumb)
    {
      artist->InsertEndChild(*thumb);
      thumb = thumb->NextSibling("thumb");
    }
  }
  XMLUtils::SetString(artist,        "path", strPath);
  if (fanart.m_xml.size())
  {
    TiXmlDocument doc;
    doc.Parse(fanart.m_xml);
    artist->InsertEndChild(*doc.RootElement());
  }

  // albums
  for (vector< pair<CStdString,CStdString> >::const_iterator it = discography.begin(); it != discography.end(); ++it)
  {
    // add a <album> tag
    TiXmlElement cast("album");
    TiXmlNode *node = artist->InsertEndChild(cast);
    TiXmlElement title("title");
    TiXmlNode *titleNode = node->InsertEndChild(title);
    TiXmlText name(it->first);
    titleNode->InsertEndChild(name);
    TiXmlElement year("year");
    TiXmlNode *yearNode = node->InsertEndChild(year);
    TiXmlText name2(it->second);
    yearNode->InsertEndChild(name2);
  }

  return true;
}
开发者ID:Ayu222,项目名称:android,代码行数:58,代码来源:Artist.cpp

示例13: ParseCrashInfo

int ParseCrashInfo(LPCSTR text, CString& sAppName, CString& sImageName,
  CString& sSubject, CString& sMailTo, CString& sUrl, UINT (*puPriorities)[3], CString& sZipName)
{  
  TiXmlDocument doc;
  doc.Parse(text);
  if(doc.Error())
    return 1;

  TiXmlHandle hRoot = doc.FirstChild("crashrpt");
  if(hRoot.ToElement()==NULL)
    return 1;

  const char* pszAppName = hRoot.ToElement()->Attribute("appname");
  const char* pszImageName = hRoot.ToElement()->Attribute("imagename");
  const char* pszSubject = hRoot.ToElement()->Attribute("subject");
  const char* pszMailTo = hRoot.ToElement()->Attribute("mailto");
  const char* pszUrl = hRoot.ToElement()->Attribute("url");
  const char* pszZipName = hRoot.ToElement()->Attribute("zipname");
  const char* pszHttpPriority = hRoot.ToElement()->Attribute("http_priority");
  const char* pszSmtpPriority = hRoot.ToElement()->Attribute("smtp_priority");
  const char* pszMapiPriority = hRoot.ToElement()->Attribute("mapi_priority");

  if(pszAppName)
    sAppName = pszAppName;

  if(pszImageName)
    sImageName = pszImageName;

  if(pszSubject)
    sSubject = pszSubject;

  if(pszMailTo!=NULL)
    sMailTo = pszMailTo;

  if(pszUrl!=NULL)
    sUrl = pszUrl;

  if(pszZipName!=NULL)
    sZipName = pszZipName;

  if(pszHttpPriority!=NULL)
    (*puPriorities)[CR_HTTP] = atoi(pszHttpPriority);
  else
    (*puPriorities)[CR_HTTP] = 0;

  if(pszSmtpPriority!=NULL)
    (*puPriorities)[CR_SMTP] = atoi(pszSmtpPriority);
  else
    (*puPriorities)[CR_SMTP] = 0;

  if(pszMapiPriority!=NULL)
    (*puPriorities)[CR_SMAPI] = atoi(pszMapiPriority);
  else
    (*puPriorities)[CR_SMAPI] = 0;
  
  return 0;
}
开发者ID:doo,项目名称:CrashRpt,代码行数:57,代码来源:CrashSender.cpp

示例14: LoadXML

void CSvsFile::LoadXML()
{
	UnloadXML();
	TiXmlDocument XmlDoc;
	XmlDoc.SetCondenseWhiteSpace(false);
	ifstream iXML( m_strFile.c_str() );
	if (!iXML)
	{
		GenErr("技能配置表转换文件读取错误", m_strFile);
	}
	iXML>>XmlDoc;
	iXML.close();

	TiXmlNode* pBody = XmlDoc.FirstChild("body");
	TiXmlNode* pTable = pBody->FirstChild("table");

	for ( TiXmlNode* pTr = pTable->FirstChild(); pTr; pTr = pTr->NextSibling() )
	{
		TiXmlElement* pElemet = pTr->ToElement();
		if (!pElemet)
			continue;

		if(pElemet->ValueStr() != "tr")
			continue;

		m_vecTR.resize(m_vecTR.size() + 1);
		TableRow& vecTD = m_vecTR.back();		
		for ( TiXmlNode* pTd = pTr->FirstChild(); pTd; pTd=pTd->NextSibling() )
		{
			TiXmlElement* pElemet = pTd->ToElement();
			if (!pElemet)
				continue;

			if(pElemet->ValueStr() != "td")
				continue;

			TiXmlNode* pParagraph = pTd->FirstChild();
			TiXmlElement* pParaElemet = pParagraph->ToElement();
			if(!pParaElemet || pParaElemet->ValueStr() != "p")
			{
				GenErr("<td>读取<p>不存在");
			}

			TableData aTD;

			aTD.m_eTDType = GetTableDataType(pParaElemet->Attribute("t"));
			if(pParaElemet->FirstChild())
			{
				aTD.m_sTDValue = utf8_to_gbk(pParaElemet->GetText());
				XMLDecode(aTD.m_sTDValue);
			}

			vecTD.push_back(aTD);
		}
	}
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:56,代码来源:CSvsFile.cpp

示例15: yDebug

RobotInterface::Robot& RobotInterface::XMLReader::Private::readRobotFile(const std::string &fileName)
{
    filename = fileName;
#ifdef WIN32
    std::replace(filename.begin(), filename.end(), '/', '\\');
#endif

    curr_filename = fileName;
#ifdef WIN32
    path = filename.substr(0, filename.rfind("\\"));
#else // WIN32
    path = filename.substr(0, filename.rfind("/"));
#endif //WIN32

    yDebug() << "Reading file" << filename.c_str();
    TiXmlDocument *doc = new TiXmlDocument(filename.c_str());
    if (!doc->LoadFile()) {
        SYNTAX_ERROR(doc->ErrorRow()) << doc->ErrorDesc();
    }

    if (!doc->RootElement()) {
        SYNTAX_ERROR(doc->Row()) << "No root element.";
    }

    for (TiXmlNode* childNode = doc->FirstChild(); childNode != 0; childNode = childNode->NextSibling()) {
        if (childNode->Type() == TiXmlNode::TINYXML_UNKNOWN) {
            if(dtd.parse(childNode->ToUnknown(), curr_filename)) {
                break;
            }
        }
    }

    if (!dtd.valid()) {
        SYNTAX_WARNING(doc->Row()) << "No DTD found. Assuming version robotInterfaceV1.0";
        dtd.setDefault();
        dtd.type = RobotInterfaceDTD::DocTypeRobot;
    }

    if(dtd.type != RobotInterfaceDTD::DocTypeRobot) {
        SYNTAX_WARNING(doc->Row()) << "Expected document of type" << DocTypeToString(RobotInterfaceDTD::DocTypeRobot)
                                       << ". Found" << DocTypeToString(dtd.type);
    }

    if(dtd.majorVersion != 1 || dtd.minorVersion != 0) {
        SYNTAX_WARNING(doc->Row()) << "Only robotInterface DTD version 1.0 is supported";
    }

    readRobotTag(doc->RootElement());
    delete doc;

    // yDebug() << robot;

    return robot;
}
开发者ID:AbuMussabRaja,项目名称:icub-main,代码行数:54,代码来源:XMLReader.cpp


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