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


C++ IXMLDOMNode::get_xml方法代码示例

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


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

示例1: ClearChildrenTail

void SettingsXML::ClearChildrenTail(IXMLDOMNode* apNode, IXMLDOMNode* apFirstClear)
{
	HRESULT hr;
	IXMLDOMNode* pNext = NULL;
	IXMLDOMNode *pNodeRmv = NULL;
	DOMNodeType  nodeType = NODE_INVALID;

	#ifdef _DEBUG
	BSTR bsDebug = NULL;
	if (pNext)
	{
		pNext->get_nodeType(&nodeType);
		pNext->get_xml(&bsDebug);
	}
	if (bsDebug) ::SysFreeString(bsDebug); bsDebug = NULL;
	#endif

	while (((hr = apFirstClear->get_nextSibling(&pNext)) == S_OK) && pNext)
	{
		pNext->get_nodeType(&nodeType);

		#ifdef _DEBUG
		pNext->get_xml(&bsDebug);
		if (bsDebug) ::SysFreeString(bsDebug); bsDebug = NULL;
		#endif

		hr = apNode->removeChild(pNext, &pNodeRmv);
		if (SUCCEEDED(hr) && (nodeType != NODE_TEXT))
			SetDataChanged();

		SafeRelease(pNodeRmv);
		SafeRelease(pNext);
	}

	apFirstClear->get_nodeType(&nodeType);
	hr = apNode->removeChild(apFirstClear, &pNodeRmv);
	if (SUCCEEDED(hr) && (nodeType != NODE_TEXT))
		SetDataChanged();

	SafeRelease(pNodeRmv);
	SafeRelease(apFirstClear);
}
开发者ID:huyiice,项目名称:ConEmu,代码行数:42,代码来源:Registry.cpp

示例2: queryNodes

void queryNodes()
{
    HRESULT hr = S_OK;
    IXMLDOMDocument *pXMLDom = NULL;
    IXMLDOMNodeList *pNodes = NULL;
    IXMLDOMNode *pNode = NULL;

    BSTR bstrQuery1 = NULL;
    BSTR bstrQuery2 = NULL;
    BSTR bstrNodeName = NULL;
    BSTR bstrNodeValue = NULL;
    VARIANT_BOOL varStatus;
    VARIANT varFileName;
    VariantInit(&varFileName);

    CHK_HR(CreateAndInitDOM(&pXMLDom));

    CHK_HR(VariantFromString(L"stocks.xml", varFileName));
    CHK_HR(pXMLDom->load(varFileName, &varStatus));
    if (varStatus != VARIANT_TRUE)
    {
        CHK_HR(ReportParseError(pXMLDom, "Failed to load DOM from stocks.xml."));
    }

    // Query a single node.
    bstrQuery1 = SysAllocString(L"//stock[1]/*");
    CHK_ALLOC(bstrQuery1);
    CHK_HR(pXMLDom->selectSingleNode(bstrQuery1, &pNode));
    if (pNode)
    {
        printf("Result from selectSingleNode:\n");
        CHK_HR(pNode->get_nodeName(&bstrNodeName));
        printf("Node, <%S>:\n", bstrNodeName);
        SysFreeString(bstrNodeName);

        CHK_HR(pNode->get_xml(&bstrNodeValue));
        printf("\t%S\n\n", bstrNodeValue);
        SysFreeString(bstrNodeValue);
        SAFE_RELEASE(pNode);
    }
    else
    {
        CHK_HR(ReportParseError(pXMLDom, "Error while calling selectSingleNode."));
    }

    // Query a node-set.
    bstrQuery2 = SysAllocString(L"//stock[1]/*");
    CHK_ALLOC(bstrQuery2);
    CHK_HR(pXMLDom->selectNodes(bstrQuery2, &pNodes));
    if(pNodes)
    {
        printf("Results from selectNodes:\n");
        //get the length of node-set
        long length;
        CHK_HR(pNodes->get_length(&length));
        for (long i = 0; i < length; i++)
        {
            CHK_HR(pNodes->get_item(i, &pNode));
            CHK_HR(pNode->get_nodeName(&bstrNodeName));
			/*if(0== wcscmp(bstrNodeValue, L"symbol"))
			{
				 
			}
           */
			printf("Node (%d), <%S>:\n", i, bstrNodeName);
            SysFreeString(bstrNodeName);

            CHK_HR(pNode->get_xml(&bstrNodeValue));
			
            printf("\t%S\n", bstrNodeValue);
            SysFreeString(bstrNodeValue);
            SAFE_RELEASE(pNode);
        }
    }
    else
    {
        CHK_HR(ReportParseError(pXMLDom, "Error while calling selectNodes."));
    }

CleanUp:
    SAFE_RELEASE(pXMLDom);
    SAFE_RELEASE(pNodes);
    SAFE_RELEASE(pNode);
    SysFreeString(bstrQuery1);
    SysFreeString(bstrQuery2);
    SysFreeString(bstrNodeName);
    SysFreeString(bstrNodeValue);
    VariantClear(&varFileName);
}
开发者ID:maheshmahajanplk,项目名称:Continuum,代码行数:89,代码来源:XMLParsing.cpp


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