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


C++ IXMLDOMDocument::loadXML方法代码示例

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


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

示例1: do_CheckXML

int do_CheckXML(lua_State* L)
{
	CString strXml = luaL_checkstring(L,1);

	HRESULT hr;
	IXMLDOMDocument * pXMLDoc;
	//...
	hr = CoInitialize(NULL); 
	// Check the return value, hr...
	hr = CoCreateInstance(CLSID_DOMDocument30, NULL, CLSCTX_INPROC_SERVER, 
		   IID_IXMLDOMDocument, (void**)&pXMLDoc);
	// Check the return value, hr...
	VARIANT_BOOL bSuccessful;
	pXMLDoc->loadXML(strXml.AllocSysString(),&bSuccessful);
	int irez = 0;
	if(!bSuccessful)
	{
		IXMLDOMParseError *pIParseError = NULL;
		pXMLDoc->get_parseError(&pIParseError);

		long lineNum;
		pIParseError->get_line(&lineNum);
		
		long linePos;
		pIParseError->get_linepos(&linePos);

		BSTR reason;
		pIParseError->get_reason(&reason);

		lua_pushinteger(L, lineNum);
		lua_pushinteger(L, linePos);
		lua_pushstring(L, CString(reason));

		pIParseError->Release();
		pIParseError = NULL;
		irez = 3;

	}
	pXMLDoc->Release();

	return irez;
}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:42,代码来源:mblua.cpp

示例2: GetDefaultXml

HRESULT
CIhvProfileBase::LoadXml
(
    IN  BSTR    bstrProfileData
)
{
    HRESULT             hr              =   S_OK;
    IXMLDOMDocument*    pDOMDoc         =   NULL;
    IXMLDOMElement*     pDocElem        =   NULL;
    BSTR                bstrIhvProfile  =   NULL;
    VARIANT_BOOL        vfSuccess;

    if ( !bstrProfileData )
    {
        hr = GetDefaultXml( &bstrIhvProfile );
        BAIL_ON_FAILURE( hr );
    }
    else
    {
		bstrIhvProfile = bstrProfileData;
    }

    if ( m_pRootNode )
    {
        hr = E_UNEXPECTED;
        BAIL_ON_FAILURE( hr );
    }

    hr =
    CoCreateInstance
    (
        CLSID_DOMDocument,
        NULL,
        CLSCTX_ALL,
        IID_IXMLDOMDocument,
        (LPVOID *) &pDOMDoc
    );
    BAIL_ON_FAILURE( hr );

    hr =
    pDOMDoc->loadXML
    (
        bstrIhvProfile,
        &vfSuccess
    );
    BAIL_ON_FAILURE( hr );

    if ( VARIANT_TRUE != vfSuccess )
    {
        hr = E_UNEXPECTED;
        BAIL_ON_FAILURE( hr );
    }

    hr =
    pDOMDoc->get_documentElement
    (
        &pDocElem
    );
    BAIL_ON_FAILURE( hr );

    // Caching the pointer to the document element
    // in a member variable.
    m_pRootNode =   pDocElem;
    pDocElem    =   NULL;


error:
    if ( !bstrProfileData )
    {
	    SYS_FREE_STRING( bstrIhvProfile );
    }
    RELEASE_INTERFACE( pDOMDoc  );
    RELEASE_INTERFACE( pDocElem );
    return hr;
}
开发者ID:340211173,项目名称:Windows-driver-samples,代码行数:75,代码来源:IHVSampleProfile.cpp

示例3: put_RecognitionParam

STDMETHODIMP CStrokeRecognition::put_RecognitionParam(BSTR newVal)
{
	double		Segment_Error_Threshold;
	double		Arc_Error_Threshold;
	double		Arc_Min_Length;
	double		Arc_Min_Curve;
	double		Stroke_Min_Length;
	double		Min_Turning_Angle;
	double		Segmentation_Penalty;
	VARIANT		value;
	BSTR		nodeName;
	long		n;

	IXMLDOMDocument*		pDoc;
	IXMLDOMNodeList*		pNodeList;
	IXMLDOMNode*			pNode;
	IXMLDOMNode*			pParamNode;
	IXMLDOMNode*			pAttrNode;
	IXMLDOMNamedNodeMap*	pNodeMap;
	VARIANT_BOOL			bLoaded;

	GetFittingParam(Segment_Error_Threshold, Arc_Error_Threshold, Arc_Min_Length, Arc_Min_Curve, Stroke_Min_Length, Min_Turning_Angle, Segmentation_Penalty);

	if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc)))
	{
		pDoc->put_async(VARIANT_FALSE);
		pDoc->loadXML(newVal, &bLoaded);

		if (bLoaded == VARIANT_TRUE)
		{
			if (SUCCEEDED(pDoc->get_childNodes(&pNodeList)))
			{
				pParamNode = NULL;

				pNodeList->get_length(&n);

				for (int i = 0; i < n; i++)
				{
					if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
					{
						nodeName = NULL;
						if (SUCCEEDED(pNode->get_nodeName(&nodeName)))
						{
							if (CComBSTR(nodeName) == L"param")
							{
								pParamNode = pNode;
								pParamNode->AddRef();
								break;
							}
							SysFreeString(nodeName);
						}
						pNode->Release();
					}
				}

				pNodeList->Release();

				if (pParamNode != NULL)
				{
					if (SUCCEEDED(pParamNode->get_attributes(&pNodeMap)))
					{
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Segment_Error_Threshold", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Segment_Error_Threshold = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Error_Threshold", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Arc_Error_Threshold = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Length", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Arc_Min_Length = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Arc_Min_Curve", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Arc_Min_Curve = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Stroke_Min_Length", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Stroke_Min_Length = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Min_Turning_Angle", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
							Min_Turning_Angle = _wtof(value.bstrVal);
							pAttrNode->Release();
						}
						if (SUCCEEDED(pNodeMap->getNamedItem(L"Segmentation_Penalty", &pAttrNode)))
						{
							pAttrNode->get_nodeValue(&value);
//.........这里部分代码省略.........
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:101,代码来源:StrokeRecognition.cpp

示例4: DecodePointFromXML

void CStrokeRecognition::DecodePointFromXML(std::vector<POINT> &rgPoints, BSTR strXML)
{
	IXMLDOMDocument*		pDoc;
	IXMLDOMNodeList*		pNodeList;
	IXMLDOMNode*			pNode;
	IXMLDOMNode*			pInputNode;
	IXMLDOMNode*			pAttrNode;
	IXMLDOMNamedNodeMap*	pNodeMap;
	VARIANT_BOOL			bLoaded;
	VARIANT					value;
	BSTR					nodeName;
	POINT					pt;
	long					n;

	if (SUCCEEDED(CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (LPVOID*)&pDoc)))
	{
		pDoc->put_async(VARIANT_FALSE);
		pDoc->loadXML(strXML, &bLoaded);

		if (bLoaded == VARIANT_TRUE)
		{
			if (SUCCEEDED(pDoc->get_childNodes(&pNodeList)))
			{
				pInputNode = NULL;

				pNodeList->get_length(&n);

				for (int i = 0; i < n; i++)
				{
					if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
					{
						nodeName = NULL;
						if (SUCCEEDED(pNode->get_nodeName(&nodeName)))
						{
							if (CComBSTR(nodeName) == L"input")
							{
								pInputNode = pNode;
								pInputNode->AddRef();
								break;
							}
							SysFreeString(nodeName);
						}
						pNode->Release();
					}
				}

				pNodeList->Release();

				if (pInputNode != NULL)
				{
					if (SUCCEEDED(pInputNode->get_childNodes(&pNodeList)))
					{
						pNodeList->get_length(&n);

						for (int i = 0; i < n; i++)
						{
							if (SUCCEEDED(pNodeList->get_item(i, &pNode)))
							{
								pt.x = 0;
								pt.y = 0;

								if (SUCCEEDED(pNode->get_attributes(&pNodeMap)))
								{
									if (SUCCEEDED(pNodeMap->getNamedItem(L"x", &pAttrNode)))
									{
										pAttrNode->get_nodeValue(&value);
										pt.x = _wtoi(value.bstrVal);
										pAttrNode->Release();
									}

									if (SUCCEEDED(pNodeMap->getNamedItem(L"y", &pAttrNode)))
									{
										pAttrNode->get_nodeValue(&value);
										pt.y = _wtoi(value.bstrVal);
										pAttrNode->Release();
									}

									pNodeMap->Release();
								}

								rgPoints.push_back(pt);

								pNode->Release();
							}
						}

						pNodeList->Release();
					}

					pInputNode->Release();
				}
			}
		}

		pDoc->Release();
	}
}
开发者ID:sanyaade-g2g-repos,项目名称:quickdiagram,代码行数:97,代码来源:StrokeRecognition.cpp

示例5: OnLoadCatalog

LRESULT CAddVideoHtmlDlg::OnLoadCatalog(WPARAM wParam, LPARAM lParam)
{
	if(wParam == NULL)
	{
		MessageBox(TEXT("获取视频分类数据失败,请检查您的网络情况。"), TEXT("错误"), MB_OK|MB_ICONERROR);
		return 0;
	}

	try
	{
		TSTLSTRING strCatalogHtml;
		int iSelectedIndex = -1;

		IXMLDOMDocument* pDOM = NULL;
		HRESULT hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, IID_IXMLDOMDocument, (void**)&pDOM);
		if(hr != S_OK)
		{
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		VARIANT_BOOL loaded = VARIANT_FALSE;
		hr = pDOM->loadXML(CComBSTR((LPCOLESTR)wParam), &loaded);
		if(hr != S_OK || loaded == VARIANT_FALSE)
		{
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNodeList* pNodeList = NULL;
		hr = pDOM->get_childNodes(&pNodeList);
		if(hr != S_OK)
		{
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNode* pRoot = NULL;
		hr = pNodeList->get_item(1, &pRoot);
		if(hr != S_OK)
		{
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNodeList* pRootChildren = NULL;
		hr = pRoot->get_childNodes(&pRootChildren);
		if(hr != S_OK)
		{
			pRoot->Release();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNode* pResultNote = NULL;
		hr = pRootChildren->get_item(0, &pResultNote);
		if(hr != S_OK)
		{
			pRootChildren->Release();
			pRoot->Release();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNodeList* pResultChildren = NULL;
		hr = pResultNote->get_childNodes(&pResultChildren);
		if(hr != S_OK)
		{
			pResultNote->Release();
			pRootChildren->Release();
			pRoot->Release();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		IXMLDOMNode* pResultStatusNote = NULL;
		hr = pRootChildren->get_item(0, &pResultStatusNote);
		if(hr != S_OK)
		{
			pResultChildren->Release();
			pResultNote->Release();
			pRootChildren->Release();
			pRoot->Release();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		CComBSTR bstrResultStatus;
		hr = pResultStatusNote->get_text(&bstrResultStatus);
		if(hr != S_OK)
		{
			pResultStatusNote->Release();
			pResultChildren->Release();
			pResultNote->Release();
			pRootChildren->Release();
			pRoot->Release();
//.........这里部分代码省略.........
开发者ID:NickeyWoo,项目名称:EditorAssistant,代码行数:101,代码来源:AddVideoHtmlDlg.cpp

示例6: XMLToScanParam

///////////////////////////////////////////////////////////////
// 功能: XML 文档文本转换成扫描参数结构
// 参数: sXMLDocText	[in]	XML文档的文本
//		 sp				[out]	扫描参数结构
// 返回: true - 成功, false - 失败
bool ScanParamXML::XMLToScanParam( const string &sXMLDocText, ScanParameter &sp )
{
	try
	{
		IXMLDOMDocument *pXmlDoc = NULL;
		IXMLDOMNode *pXmlDomNode = NULL;
			
		// 得到关于IXMLDOMDocument 接口的指针 pXMLDOC
		HRESULT hr = ::CoCreateInstance( CLSID_DOMDocument,
										NULL, 
										CLSCTX_INPROC_SERVER,
										IID_IXMLDOMDocument, 
										( void ** )&pXmlDoc );
		if( S_OK != hr )
		{
			return false;
		}

		//得到关于IXMLDOMNode接口的指针pXDN 
		hr = pXmlDoc->QueryInterface( IID_IXMLDOMNode,
									( void ** )&pXmlDomNode );
		if( S_OK != hr )
		{
			return false;
		}
		
		VARIANT_BOOL bOk;
		_variant_t varSrc = sXMLDocText.c_str();
		IXMLDOMElement *pRootNode;	// 根结点
		IXMLDOMNode *pNode;
		IXMLDOMNode *pNodeOut;
		
		pXmlDoc->loadXML( varSrc.bstrVal, &bOk  );	// 从字符串建立XML文档

		// 取得根结点
		pXmlDoc->get_documentElement( &pRootNode );		
		pRootNode->get_nodeName( &varSrc.bstrVal );

		// 遍历根结点的子结点
		for( pRootNode->get_firstChild( &pNode );
			pNode != NULL; pNode->get_nextSibling( &pNode ) )
		{
			pNode->get_nodeName( &varSrc.bstrVal );
			// cout << "Node name: " << varSrc.operator _bstr_t().operator char *() << endl;

			string sNodeName = _bstr_t( varSrc.bstrVal ).operator char *();
			if( sNodeName == string( "Depth" ) )
			{	// 发现 Depth 结点
				varSrc = ReadNodeText( pNode );
				sp.nDepth = atoi( _bstr_t( varSrc.bstrVal ).operator char *() );

				//cout << "Depth value: " << sp.nDepth << endl;
			}
			else if( sNodeName == string( "TryTimes" ) )
			{	// 发现 TryTimes 结点
				varSrc = ReadNodeText( pNode );
				sp.nTryTimes = atoi( _bstr_t( varSrc.bstrVal ).operator char *() );

				//cout << "TryTimes value: " << sp.nTryTimes << endl;
			}	
			else if( sNodeName == string( "Timeout" ) )
			{	// 发现 Timeout 结点
				varSrc = ReadNodeText( pNode );
				sp.nTimeout = atoi( _bstr_t( varSrc.bstrVal ).operator char *() );

				//cout << "Timeout value: " << sp.nTimeout << endl;
			}		
			else if( sNodeName == string( "MaxTreadCount" ) )
			{	// 发现 MaxTreadCount 结点
				varSrc = ReadNodeText( pNode );
				sp.nMaxTreadCount = atoi( _bstr_t( varSrc.bstrVal ).operator char *() );

				//cout << "MaxTreadCount value: " << sp.nMaxTreadCount << endl;
			}
			else if( sNodeName == string( "SubScan" ) )
			{	// 发现 SubScan 结点
				varSrc = ReadNodeText( pNode );
				sp.bSubScan = ( string( _bstr_t( varSrc.bstrVal ).operator char *() ) == XML_TRUE ) ;

				//cout << "SubScan value: " << sp.bSubScan << endl;
			}		
			else if( sNodeName == string( "DefaultCommunityGet" ) )
			{	// 发现 DefaultCommunityGet 结点
				varSrc = ReadNodeText( pNode );
				sp.sDefaultCommunityOfGet = _bstr_t( varSrc.bstrVal ).operator char *();

				//cout << "DefaultCommunityGet value: " << sp.sDefaultCommunityOfGet << endl;
			}		
			else if( sNodeName == string( "DefaultCommunitySet" ) )
			{	// 发现 DefaultCommunitySet 结点
				varSrc = ReadNodeText( pNode );
				sp.sDefaultCommunityOfSet = _bstr_t( varSrc.bstrVal ).operator char *();

				//cout << "DefaultCommunityOfSet value: " << sp.sDefaultCommunityOfSet << endl;
			}		
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: XmlLoadDocumentEx

/********************************************************************
 XmlLoadDocumentEx -

*********************************************************************/
extern "C" HRESULT DAPI XmlLoadDocumentEx(
    __in_z LPCWSTR wzDocument,
    __in DWORD dwAttributes,
    __out IXMLDOMDocument** ppixdDocument
    )
{
    HRESULT hr = S_OK;
    VARIANT_BOOL vbSuccess = 0;

    // RELEASEME
    IXMLDOMDocument* pixd = NULL;
    IXMLDOMParseError* pixpe = NULL;
    BSTR bstrLoad = NULL;

    if (!wzDocument || !*wzDocument)
    {
        hr = E_UNEXPECTED;
        ExitOnFailure(hr, "string must be non-null");
    }

    hr = XmlCreateDocument(NULL, &pixd);
    if (hr == S_FALSE)
    {
        hr = E_FAIL;
    }
    ExitOnFailure(hr, "failed XmlCreateDocument");

    if (dwAttributes & XML_LOAD_PRESERVE_WHITESPACE)
    {
        hr = pixd->put_preserveWhiteSpace(VARIANT_TRUE);
        ExitOnFailure(hr, "failed put_preserveWhiteSpace");
    }

    // Security issue.  Avoid triggering anything external.
    hr = pixd->put_validateOnParse(VARIANT_FALSE);
    ExitOnFailure(hr, "failed put_validateOnParse");
    hr = pixd->put_resolveExternals(VARIANT_FALSE);
    ExitOnFailure(hr, "failed put_resolveExternals");

    bstrLoad = ::SysAllocString(wzDocument);
    ExitOnNull(bstrLoad, hr, E_OUTOFMEMORY, "failed to allocate bstr for Load in XmlLoadDocumentEx");

    hr = pixd->loadXML(bstrLoad, &vbSuccess);
    if (S_FALSE == hr)
    {
        hr = HRESULT_FROM_WIN32(ERROR_OPEN_FAILED);
    }

    if (FAILED(hr) && S_OK == pixd->get_parseError(&pixpe))
    {
        XmlReportParseError(pixpe);
    }

    ExitOnFailure(hr, "failed loadXML");


    hr = S_OK;
LExit:
    if (ppixdDocument)
    {
        *ppixdDocument = pixd;
        pixd = NULL;
    }
    ReleaseBSTR(bstrLoad);
    ReleaseObject(pixd);
    ReleaseObject(pixpe);

    return hr;
}
开发者ID:925coder,项目名称:wix3,代码行数:73,代码来源:xmlutil.cpp


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