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


C++ XML_PARSER::Go_to_Root方法代码示例

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


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

示例1: Onsave

int CFileListXml::Onsave(const CString& strFileTemp)
{
	CString strFile = strFileTemp;
	if (strFile.IsEmpty())  //调用者未设置保存路径,选择上次加载的路径
	{
		strFile = m_strFileListXML;

		if (strFile.IsEmpty())  //还是空
		{
			return Error_File_List_Path_Is_NULL;
		}
	}	

	XML_PARSER parser;
	if (!parser.Load_XML_String("<?xml version=\"1.0\" encoding=\"utf-8\" ?><root version=\"2.0\"/>"))
	{
		return Error_File_List_Load_Xml_Declaration;
	}

	//项目名称
	parser.Add_LastChildElement(NODE_Project);
	SetAttribute(parser, ATTRIBUTE_Project_Name, m_strProjectName);
	parser.Go_to_Root();

	//X86节点及文件列表
	parser.Add_LastChildElement(NODE_X86);
	for (vector<FILE_ITEM>::const_iterator it=m_x86FileList.begin(); it!=m_x86FileList.end(); it++)
	{
		parser.Add_LastChildElement(NODE_ITEM);
		SetAttribute(parser, ATTRIBUTE_ITEM_Name, it->strName);
		SetAttribute(parser, ATTRIBUTE_ITEM_Source_Path, it->strSrcPath);
		SetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path, it->strDestPath);
		parser.Go_to_Parent(NODE_X86);
	}
	parser.Go_to_Root();

	//X64节点及文件列表
	parser.Add_LastChildElement(NODE_X64);
	for (vector<FILE_ITEM>::const_iterator it=m_x64FileList.begin(); it!=m_x64FileList.end(); it++)
	{
		parser.Add_LastChildElement(NODE_ITEM);
		SetAttribute(parser, ATTRIBUTE_ITEM_Name, it->strName);
		SetAttribute(parser, ATTRIBUTE_ITEM_Source_Path, it->strSrcPath);
		SetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path, it->strDestPath);
		parser.Go_to_Parent(NODE_X64);
	}
	parser.Go_to_Root();

	//保存到文件
	if (!parser.Save_XML_Document(strFile))
	{
		return Error_File_List_Unknown_Reason;
	}
	else
	{
		return Error_File_List_Success;
	}
}
开发者ID:yuechuanbingzhi163,项目名称:sixhe,代码行数:58,代码来源:FileList.cpp

示例2: Onload

int CFileListXml::Onload(const void* param)
{
	m_strFileListXML = _T("");	//上一次加载的文件路径清空
	CString strFile = (LPCTSTR)param;
	if (!CPathUtilEx::IsFileExist(strFile))
	{
		return Error_File_List_File_Is_Not_Exist;
	}

	XML_PARSER parser;
	if (!parser.Load_XML_Document(strFile))
	{
		return Error_File_List_Xml_Format_Wrong;
	}

	//项目名称
	if (parser.Go_to_Child(NODE_Project))
	{
		m_strProjectName = GetAttribute(parser, ATTRIBUTE_Project_Name);
	}
	parser.Go_to_Root();

	//X86文件列表
	if (parser.Go_to_Child(NODE_X86) && parser.Go_to_Child(NODE_ITEM))
	{
		do 
		{
			FILE_ITEM item;
			item.strName = GetAttribute(parser, ATTRIBUTE_ITEM_Name);
			item.strSrcPath = GetAttribute(parser, ATTRIBUTE_ITEM_Source_Path);
			item.strDestPath =GetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path);			
			m_x86FileList.push_back(item);

		} while (parser.Go_to_NextSibling(NODE_ITEM));
	}
	parser.Go_to_Root();

	//X64文件列表
	if (parser.Go_to_Child(NODE_X64) && parser.Go_to_Child(NODE_ITEM))
	{
		do 
		{
			FILE_ITEM item;
			item.strName = GetAttribute(parser, ATTRIBUTE_ITEM_Name);
			item.strSrcPath = GetAttribute(parser, ATTRIBUTE_ITEM_Source_Path);
			item.strDestPath = GetAttribute(parser, ATTRIBUTE_ITEM_Dest_Path);			
			m_x64FileList.push_back(item);

		} while (parser.Go_to_NextSibling(NODE_ITEM));
	}
	parser.Go_to_Root();

	m_strFileListXML = strFile;		//以便保存时无需设置路径
	return Error_File_List_Success;
}
开发者ID:yuechuanbingzhi163,项目名称:sixhe,代码行数:55,代码来源:FileList.cpp


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