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


C++ IXMLDOMElementPtr::selectNodes方法代码示例

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


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

示例1: sizeof

bool CPbl2XML::Convert(MSXML2::IXMLDOMElementPtr &library, _bstr_t &path)
{
	MSXML2::IXMLDOMElementPtr childnode = library->ownerDocument->
		createElement("childs");

	char buffer[256] = {0};

	int iResult = m_orca.LibraryDirectory((char *) path, 
		buffer, sizeof(buffer),	LibDir, (LPVOID) childnode.GetInterfacePtr());

	if(iResult != PBORCA_OK) {
		CString msg; msg.Format("FAILED: LibraryDirectory(...) : %s", (char *) path);
		log.write(msg);
		
		childnode = NULL;
		return false;
	}

	_bstr_t xpath("childs");
	MSXML2::IXMLDOMNodeListPtr childlist = library->selectNodes(xpath);

	if(childlist->length > 0) {
		library->replaceChild(childnode, childlist->item[0]);
	} else {
		library->appendChild(childnode);
	}

	// сохраняем значение комментария библиотеки
	library->setAttribute(_bstr_t("comment"), _bstr_t(buffer));

	return true;
}
开发者ID:vactorwu,项目名称:pbrebus,代码行数:32,代码来源:Pbl2XML.cpp

示例2: GetGroupCount

long CIconImgList::GetGroupCount( MSXML2::IXMLDOMElementPtr piGroups)
{
    long lCount = 0;

    MSXML2::IXMLDOMNodeListPtr piGroupsList;
    piGroupsList = piGroups->selectNodes( _bstr_t( _T( "GROUP")));
    if( NULL != piGroupsList)
    {
        long lChildCount = piGroupsList->Getlength();

        lCount = lChildCount;

        MSXML2::IXMLDOMElementPtr piGroupChild;
        for( long lIndex = 0; lIndex < lChildCount; lIndex++)
        {
            piGroupChild = piGroupsList->Getitem( lIndex);
            lCount += GetGroupCount( piGroupChild);
        }
    }
    return lCount;
}
开发者ID:sayrun,项目名称:SOboe,代码行数:21,代码来源:IconImgList.cpp

示例3: parseRootTsl

BOOL parseRootTsl(PSTR IN url, TCertListPtr IN pCertList, TURLListPtr IN URLListPtr) 
{
	BOOL ret;
	
	IXMLDOMDocument2Ptr pXMLDoc;
	LPWSTR pInsertStrings[2] = {NULL, NULL};
	LPCWSTR searchTerm;
	MSXML2::IXMLDOMElementPtr pXMLDocElement = NULL;
	MSXML2::IXMLDOMNodeListPtr pXMLDomNodeList = NULL;
	INT i;

	pInsertStrings[0] = (LPWSTR) _strdup(url);
	ret = ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE, CAT_TSL_PARSER, TSL_PARSE_START, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);

	printf("Opening %s...\n", url);

	// add currently processed URL
	ret = addUrl( url, &URLListPtr);

	// initialize XML trees
	CoInitialize(NULL);

	// attempt to fetch TSL file from Internet
	pXMLDoc = TslFetch(url);

	try{

#define DSIG_NS L"xmlns:tsl='http://uri.etsi.org/02231/v2#' xmlns:tslx='http://uri.etsi.org/02231/v2/additionaltypes#'"

		// Initialize XML parser
		pXMLDoc->async =  VARIANT_FALSE;
		pXMLDoc->setProperty("SelectionLanguage", "XPath");		// tell MSXML that we will use XPath syntax
		pXMLDoc->setProperty("SelectionNamespaces",	DSIG_NS);	// set namespace
		
		pXMLDocElement = pXMLDoc->documentElement;
	
		// Structure for root TSL (root=true)
		// OtherTSLPointer
		//	+- ServiceDigitalIdentities
		//		+- ServiceDigitalIdentity
		//			+- DigitalId
		//				+- X509Certificate	CERT - we add this to GlobalCertList
		//	+- TSLLocation					SUB-TSL - we parse this recursively
		//	+- AdditionalInformation
		//		+- OtherInformation*
		//			+- tslx:MimeType				MIME - need this to skip PDF files
		//      +- OtherInformation*
		//          +- SchemeOperatorName
		//              +- Name
		
		searchTerm = L"//tsl:TSLLocation[../tsl:AdditionalInformation/tsl:OtherInformation/tslx:MimeType='application/vnd.etsi.tsl+xml']";
		pXMLDomNodeList = pXMLDocElement->selectNodes(searchTerm);
		INT count = 0;
		count = pXMLDomNodeList->length;
		wprintf(L"XML query: %s\n", searchTerm);
		printf("Found %d nodes.\n", count);

		for(i=0; i<count; i++) {
			// process sub-TSL location
			MSXML2::IXMLDOMElementPtr current_elem = NULL;
			MSXML2::IXMLDOMElementPtr cert_elem = NULL;
			MSXML2::IXMLDOMElementPtr name_elem = NULL;
			BSTR tagName, newUrl;
			PSTR copyNewUrl;
			
			current_elem = pXMLDomNodeList->item[i]; // for root we are at TSLLocation level, for child at 
			tagName = current_elem->tagName;
			newUrl =  current_elem->text;

			copyNewUrl = (PSTR) malloc(wcslen(newUrl)*2);
			// convert URL to PSTR as this is what TslFetch expects later on
			WideCharToMultiByte(CP_ACP, 0, newUrl, -1, copyNewUrl, wcslen(newUrl)*2, NULL, NULL);

			// this part is recursively calling parseTSL()
			// need to check duplicate urls because most TSL will publish reference to EU TSL
			if(isKnownUrl((PSTR) copyNewUrl, URLListPtr) == false) {

				// fetch operator name for current certificate
				name_elem = current_elem->selectSingleNode(L"../tsl:AdditionalInformation/tsl:OtherInformation/tsl:SchemeOperatorName/tsl:Name");
				assert(name_elem != NULL);
				wprintf(L"Child TSL operator name=%s\n", (LPWSTR) name_elem->text);

				// if this TSL wasn't previously parse, do it now
				wprintf(L"Found new TSL %s=%s\n", (LPWSTR) tagName, (LPWSTR) newUrl);
				ret = parseChildTsl( copyNewUrl, pCertList, URLListPtr);

			}

			// fetch certificate
			/* this is not really needed until we verify TSL signatures
			cert_elem = current_elem->selectSingleNode(L"../tsl:ServiceDigitalIdentities/tsl:ServiceDigitalIdentity/tsl:DigitalId/tsl:X509Certificate");
			if(cert_elem == NULL) {
				printf("No certificate found in TSL: %s\n", copyNewUrl);
			} else {
				printf("Adding cert to urllist, size=%d\n", certCount(pCertList));
				// add certificate to global certificate list for further processing
				ret = addCert((PSTR) cert_elem->text, &pCertList);
			}
			*/

//.........这里部分代码省略.........
开发者ID:kravietz,项目名称:TSLwatch,代码行数:101,代码来源:parseRootTsl.cpp

示例4: parseChildTsl

BOOL parseChildTsl(PSTR IN url, TCertListPtr IN pCertList, TURLListPtr IN URLListPtr) 
{
	BOOL ret;
	
	IXMLDOMDocument2Ptr pXMLDoc;
	LPWSTR pInsertStrings[2] = {NULL, NULL};
	LPCWSTR searchTerm;
	MSXML2::IXMLDOMElementPtr pXMLDocElement = NULL;
	MSXML2::IXMLDOMNodeListPtr pXMLDomNodeList = NULL;
	INT i;

	pInsertStrings[0] = (LPWSTR) _strdup(url);
	ret = ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE, CAT_TSL_PARSER, TSL_PARSE_START, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL);

	printf("Opening child TSL %s...\n", url);

	// add currently processed URL
	ret = addUrl( url, &URLListPtr);

	// initialize XML trees
	CoInitialize(NULL);

	// attempt to fetch TSL file from Internet
	pXMLDoc = TslFetch(url);

	try{

#define DSIG_NS L"xmlns:tsl='http://uri.etsi.org/02231/v2#' xmlns:tslx='http://uri.etsi.org/02231/v2/additionaltypes#'"

		// Initialize XML parser
		pXMLDoc->async =  VARIANT_FALSE;
		pXMLDoc->setProperty("SelectionLanguage", "XPath");		// tell MSXML that we will use XPath syntax
		pXMLDoc->setProperty("SelectionNamespaces",	DSIG_NS);	// set namespace
		
		pXMLDocElement = pXMLDoc->documentElement;
	
		// Structure for child TSL (root=false)
		//tsl:TrustServiceProvider
		//	tsl:TSPInformation
		//		tsl:TSPName
		//			tsl:Name[xml:lang='en']
		//	tsl:TSPServices
		//		tsl:TSPService
		//			tsl:ServiceInformation
		//				tsl:ServiceTypeIdentifier
		//				tsl:ServiceDigitalIdentity
		//					tsl:DigitalId
		//						tsl:X509Certificate
 
		searchTerm = L"//tsl:TSPService";
		pXMLDomNodeList = pXMLDocElement->selectNodes(searchTerm);
		INT count = 0;
		count = pXMLDomNodeList->length;
		wprintf(L"XML query: %s\n", searchTerm);
		printf("Found %d nodes.\n", count);

		for(i=0; i<count; i++) {
			// process sub-TSL location
			MSXML2::IXMLDOMElementPtr current_elem = NULL;
			MSXML2::IXMLDOMElementPtr cert_elem = NULL;
			MSXML2::IXMLDOMElementPtr name_elem = NULL;
			MSXML2::IXMLDOMElementPtr service_elem = NULL;
			MSXML2::IXMLDOMElementPtr status_elem = NULL;
			
			current_elem = pXMLDomNodeList->item[i]; // at tsl:TSPService level
			wprintf(L"Found %s\n", (LPWSTR) current_elem->tagName);

			// fetch operator name for current certificate
			name_elem = current_elem->selectSingleNode(L"../../tsl:TSPInformation/tsl:TSPName/tsl:Name[@xml:lang='en']");
			assert(name_elem != NULL);
			wprintf(L"Operator name=%s\n", (LPWSTR) name_elem->text);

			// fetch service name identifier (QC, TSP etc)
			// Annex D.2 page 73 of ETSI TS 102 200
			status_elem = current_elem->selectSingleNode(L"tsl:ServiceInformation/tsl:ServiceTypeIdentifier");
			assert(status_elem != NULL);
			wprintf(L"Service id=%s\n", (LPWSTR) status_elem->text);

			// fetch service status identifier (active, discontinued etc)
			// Annex L.2 page 100 of ETSI TS 102 200
			service_elem = current_elem->selectSingleNode(L"tsl:ServiceInformation/tsl:ServiceStatus");
			assert(service_elem != NULL);
			wprintf(L"Service status=%s\n", (LPWSTR) service_elem->text);
			//assert( wcscmp(L"http://uri.etsi.org/TrstSvc/eSigDir-1999-93-EC-TrustedList/Svcstatus/undersupervision", status_elem->text) == 0);

			// fetch certificate
			cert_elem = current_elem->selectSingleNode(L"tsl:ServiceInformation/tsl:ServiceDigitalIdentity/tsl:DigitalId/tsl:X509Certificate");
			assert(cert_elem != NULL);
			printf("Adding cert to urllist, size=%d\n", certCount(pCertList));
			// add certificate to global certificate list for further processing
			ret = addCert((PSTR) cert_elem->text, &pCertList);

			if(certCount(pCertList) > 20) // XXX for faster debugging
				return true;

		} /* end of XML parsing loop */

	} // end of try block

	catch(_com_error &e)
//.........这里部分代码省略.........
开发者ID:kravietz,项目名称:TSLwatch,代码行数:101,代码来源:parseChildTsl.cpp

示例5: LoadXml

BOOL CVoucherFile::LoadXml(const CString& strFileName, VoucherFileInfo &voucherInfo)
{	
	CString strFullPath = strFileName;
	BOOL bRet = FALSE;
	try
	{
		voucherInfo.Reset();

		::CoInitialize(NULL);
		MSXML2::IXMLDOMDocumentPtr pXmlDoc(__uuidof(MSXML2::DOMDocument));
		MSXML2::IXMLDOMElementPtr pRootNode = NULL;
		CString strTemp;
		
		pXmlDoc->put_async(VARIANT_FALSE);
		pXmlDoc->load(_bstr_t(strFullPath.AllocSysString()));
		pRootNode = pXmlDoc->GetdocumentElement();
		if (pRootNode == NULL)
			return FALSE;

		// 错误类型
		MSXML2::IXMLDOMElementPtr pNode = pRootNode->selectSingleNode(_T("error"));
		if (pNode != NULL)
		{
			voucherInfo.strError = _GetNodeText(pNode);
		}

		// 模型信息
		pNode = pRootNode->selectSingleNode(_T("model"));
		if (pNode != NULL)
		{
			// 版本
			MSXML2::IXMLDOMElementPtr pChildNode = pNode->selectSingleNode(_T("version"));
			if (pChildNode != NULL)
				voucherInfo.strModelVersion = _GetNodeText(pChildNode);

			// 日期
			pChildNode = pNode->selectSingleNode(_T("date"));
			if (pChildNode != NULL)
				voucherInfo.strModelDate = _GetNodeText(pChildNode);

			// 时间
			pChildNode = pNode->selectSingleNode(_T("time"));
			if (pChildNode != NULL)
				voucherInfo.strModelTime = _GetNodeText(pChildNode);

			// 大小
			pChildNode = pNode->selectSingleNode(_T("size"));
			if (pChildNode != NULL)
				voucherInfo.strModelSize = _GetNodeText(pChildNode);
		}
		
		// 用户列表
		MSXML2::IXMLDOMElementPtr pUserNode = pRootNode->selectSingleNode(_T("nodeinfo"));
		if (pUserNode != NULL)
		{
			CString strText;
			MSXML2::IXMLDOMNodeListPtr pList = pUserNode->selectNodes(_bstr_t("username"));
			if (pList != NULL)
			{
				int nUserCount = pList->Getlength();
				for(int i = 0; i < nUserCount; i++)
				{
					MSXML2::IXMLDOMNodePtr pChiledNode = pList->Getitem(i);
					if (pChiledNode != NULL)
					{
						strText = _GetNodeText(pChiledNode);
						voucherInfo.vecUser.push_back(strText);
					}
				}
			}
		}
		bRet = TRUE;
	}
	catch (...)
	{
		bRet = FALSE;
	}
	return bRet;
}
开发者ID:bjliugq,项目名称:SmartDoctor,代码行数:79,代码来源:VoucherFile.cpp


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