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


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

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


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

示例1: 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

示例2: 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

示例3: readDatasetFile

int DicomImageSet::readDatasetFile(const QString &datasetFileName, QTreeWidget *treeWidget)
{
    HRESULT hr = S_OK;
    IXMLDOMDocument *pXMLDom = NULL;
    IXMLDOMNodeList *pPatients = NULL;
    IXMLDOMNode *pPatient = NULL;
	DOMNodeType nodeType;
    VARIANT_BOOL varStatus;
    VARIANT varFileName;
	VARIANT varValue;
	BSTR bstrQuery;

    VariantInit(&varFileName);
    VariantInit(&varValue);

	QString queryPatient, queryDate, queryProtocol, queryCollection;

    CHK_HR(CreateAndInitDOM(&pXMLDom));

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

	treeWidget->clear();
	treeWidget->setColumnCount(1);
	CHK_HR(pXMLDom->getElementsByTagName(L"Patient", &pPatients));
	if (pPatients)
	{
		long nPatients;
		CHK_HR(pPatients->get_length(&nPatients));
		for (long i=0; i<nPatients; ++i)
		{
			CHK_HR(pPatients->get_item(i, &pPatient));
			CHK_HR(GetAttributeFromNode(pPatient, L"patients_name", &varValue));
			queryPatient = QString::fromWCharArray(_bstr_t(varValue));
			QTreeWidgetItem * patientItem = new QTreeWidgetItem(treeWidget, QStringList(queryPatient));
			patientItem->setExpanded(true);

			IXMLDOMNodeList * pDates = NULL;
			CHK_HR(pPatient->get_childNodes(&pDates));
			long nDates;
			CHK_HR(pDates->get_length(&nDates));
			for (long j=0; j<nDates; ++j)
			{
				IXMLDOMNode * pDate = NULL;
				CHK_HR(pDates->get_item(j, &pDate));
				CHK_HR(pDate->get_nodeType(&nodeType));
				if(nodeType!=NODE_ELEMENT)
				{
					continue;
				}
				CHK_HR(GetAttributeFromNode(pDate, L"acquisition_date", &varValue));
				queryDate = QString::fromWCharArray(_bstr_t(varValue));
				int intDate = queryDate.toInt();
				QDate date = (QDate::fromString("1900-01-01", "yyyy-MM-dd")).addDays(intDate-693962);
				QTreeWidgetItem * dateItem = new QTreeWidgetItem(patientItem, QStringList(date.toString("yyyy-MM-dd")));
				dateItem->setExpanded(true);

				IXMLDOMNodeList * pProtocols = NULL;
				CHK_HR(pDate->get_childNodes(&pProtocols));
				long nProtocols;
				CHK_HR(pProtocols->get_length(&nProtocols));
				for (long j=0; j<nProtocols; ++j)
				{
					IXMLDOMNode * pProtocol = NULL;
					CHK_HR(pProtocols->get_item(j, &pProtocol));
					CHK_HR(pProtocol->get_nodeType(&nodeType));
					if(nodeType!=NODE_ELEMENT)
					{
						continue;
					}
					CHK_HR(GetAttributeFromNode(pProtocol, L"protocol_name", &varValue));
					queryProtocol = QString::fromWCharArray(_bstr_t(varValue));
					QTreeWidgetItem * protocolItem = new QTreeWidgetItem(dateItem, QStringList(queryProtocol));
					protocolItem->setExpanded(true);

					IXMLDOMNodeList * pCollections = NULL;
					CHK_HR(pProtocol->get_childNodes(&pCollections));
					long nCollections;
					CHK_HR(pCollections->get_length(&nCollections));
					for (long j=0; j<nCollections; ++j)
					{
						IXMLDOMNode * pCollection = NULL;
						CHK_HR(pCollections->get_item(j, &pCollection));
						CHK_HR(pCollection->get_nodeType(&nodeType));
						if(nodeType!=NODE_ELEMENT)
						{
							continue;
						}
						CHK_HR(GetAttributeFromNode(pCollection, L"acquisition_number", &varValue));
						queryCollection = QString::fromWCharArray(_bstr_t(varValue));
						QTreeWidgetItem * collectionItem = new QTreeWidgetItem(protocolItem);
						QString queryStr = QString("root/Patient[@patients_name = '%1']/Date[@acquisition_date = '%2']/Protocol[@protocol_name = '%3']/Collection[@acquisition_number = '%4']")
							.arg(queryPatient).arg(queryDate).arg(queryProtocol).arg(queryCollection);

						IXMLDOMElement * pDtiNode = NULL;
						bstrQuery = SysAllocString(QString(queryStr+"/DTI").toStdWString().c_str());
//.........这里部分代码省略.........
开发者ID:vcpudding,项目名称:DTI-Visualization,代码行数:101,代码来源:DicomImageSet.cpp

示例4: NextChildNode

bool CXML::NextChildNode()
{
	if(!m_pICurrentNode)
		return false;

	IXMLDOMNode * pNode = NULL;
	IXMLDOMNode * pITempNode = m_pICurrentNode;
	pITempNode->AddRef();

	IXMLDOMNodeList * pChildList = NULL;
	
	// Get the list of child nodes of the current node

	m_hr = pITempNode->get_childNodes(&pChildList);
	pITempNode->Release();
	if (!SUCCEEDED(m_hr))
		return false;
	// loop through the childs
	DOMNodeType nodeType;
	while(true)
	{
		// Get the node type of each child, if it is of NODE_ELEMENT type set it as current node
		m_hr = pChildList->nextNode(&pNode);
		if(!SUCCEEDED(m_hr))
		{
			pChildList->Release();
			return false;
		}
		if(!pNode) break;
		m_hr = pNode->get_nodeType(&nodeType);
		if(!SUCCEEDED(m_hr))
		{
			pChildList->Release();
			pNode->Release();
			return false;
		}

		if(nodeType == NODE_ELEMENT)
			break;
		if(pNode)
			pNode->Release();
	}

	if(pChildList)
		pChildList->Release();

	if(pNode)
	{
		if(m_pICurrentNode)
		{
			m_pICurrentNode->Release();
			m_pICurrentNode = NULL;
		}

		m_pICurrentNode = pNode;
		m_pICurrentNode->AddRef();

		pNode->Release();
		return true;
	}
	return false;
	
}
开发者ID:alexcpn,项目名称:TelephonyIVRKeyMapDemo,代码行数:63,代码来源:XML.cpp


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