BOOL CKADmerge::HasNode(IXMLDOMNode * pXMLNode, string sPatternString, IXMLDOMNode ** pXMLTarget)
{
    BOOL bRet = FALSE;
    HRESULT hRes = 0;
    LONG lListLength = 0;

    IXMLDOMNodeList * pXMLNodeList = NULL;
    _bstr_t bPatternString(sPatternString.c_str());
    hRes = pXMLNode->selectNodes(bPatternString, &pXMLNodeList);

    if(SUCCEEDED(hRes))
    {
        hRes = pXMLNodeList->get_length(&lListLength);
        if(lListLength)
        {
            hRes = pXMLNodeList->nextNode(pXMLTarget);
            bRet = TRUE;
        }
        else
        {
            string str01 = GetName(pXMLNode);
            string str02 = GetName(*pXMLTarget);
            bRet = FALSE;
        }
    }

    if(pXMLNodeList)
        pXMLNodeList->Release();

    return bRet;
}
Exemple #2
0
/** 
* загрузка и парсинг xml документа
* @param data текст загружаемого xml докуммента
* @return TRUE если всё ОК, FALSE в случае ошибки
*/
BOOL XmlLoad(PWSTR lpwcData, IXMLDOMDocument **pXMLDoc, IXMLDOMNode **pIDOMRootNode, PWSTR lpwcRootNodeName)
{
    BOOL bOk = FALSE;
    VARIANT_BOOL status;

    // initialize COM
    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    if (FAILED(hr))
    {
        DbgMsg(__FILE__, __LINE__, "CoInitializeEx() ERROR 0x%.8x\n", hr);
        return FALSE;
    }    

    // create new msxml document instance
    hr = CoCreateInstance(CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER, 
        IID_IXMLDOMDocument, (void **)pXMLDoc);
    if (FAILED(hr)) 
    {
        DbgMsg(__FILE__, __LINE__, "CoCreateInstance() ERROR 0x%.8x\n", hr);
        return FALSE;
    }    

    hr = (*pXMLDoc)->loadXML(lpwcData, &status);
    if (status != VARIANT_TRUE)
    {
        DbgMsg(__FILE__, __LINE__, "pXMLDoc->load() ERROR 0x%.8x\n", hr);
        goto end;
    }

    // если xml загружен, получаем список корневых узлов
    // из которого получаем главный подузел 'logger'
    IXMLDOMNodeList *pIDOMRootNodeList;
    hr = (*pXMLDoc)->get_childNodes(&pIDOMRootNodeList);
    if (SUCCEEDED(hr))
    {
        *pIDOMRootNode = ConfGetListNodeByName(lpwcRootNodeName, pIDOMRootNodeList);
        if (*pIDOMRootNode)
        {
            bOk = TRUE;
        }            

        pIDOMRootNodeList->Release();        
    }
    else
    {
        DbgMsg(__FILE__, __LINE__, "pXMLDoc->get_childNodes() ERROR 0x%.8x\n", hr);
    }    

end:

    if (!bOk)
    {
        // произошла ошибка
        // освобождаем дескриптор докуммента
        (*pXMLDoc)->Release();
        *pXMLDoc = NULL;
    }

    return bOk;
}
IXMLDOMNode *CXML::NextChildNode(IXMLDOMNode **ppNode)
{
	if(!(*ppNode))
		return NULL;

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

	m_hr = (*ppNode)->get_childNodes(&pChildList);
	if (!SUCCEEDED(m_hr))
		return NULL;
	// 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 NULL;
		}
		if(!pNode) break;
		m_hr = pNode->get_nodeType(&nodeType);
		if(!SUCCEEDED(m_hr))
		{
			pChildList->Release();
			pNode->Release();
			return NULL;
		}

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

	if(pChildList)
		pChildList->Release();

	return pNode;
}
// FindElements
UINT COpcXmlDocument::FindElements(const COpcString& cXPath, COpcXmlElementList& cElements)
{
    cElements.RemoveAll();

    // check if document exists.
    if (m_ipDocument == NULL)
    {
        return 0;
    }

    // search for matching nodes.
    IXMLDOMNodeList* ipNodes = NULL;

    BSTR bstrQuery = SysAllocString(cXPath);
    HRESULT hResult = m_ipDocument->selectNodes(bstrQuery, &ipNodes);
    SysFreeString(bstrQuery);

    if (FAILED(hResult))
    {
        return 0;
    }

    // add found nodes to element list.
    do
    {
        IXMLDOMNode* ipNode = NULL;

        hResult = ipNodes->nextNode(&ipNode);

        if (hResult != S_OK || ipNode == NULL)
        {
            break;
        }

        COpcXmlElement cElement(ipNode);
        ipNode->Release();

        if (cElement != NULL)
        {
            cElements.Append(cElement);
        }
    }
    while (SUCCEEDED(hResult));

    if (ipNodes != NULL)
    {
        ipNodes->Release();
    }

    // return the number of elements found.
    return cElements.GetSize();
}
long lvDCOMInterface::nParams()
{
	long n = 0;
	char control_name_xpath[MAX_PATH_LEN];
	_snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param", m_configSection.c_str());
	IXMLDOMNodeList* pXMLDomNodeList = NULL;
	HRESULT hr = m_pxmldom->selectNodes(_bstr_t(control_name_xpath), &pXMLDomNodeList);
	if (SUCCEEDED(hr) && pXMLDomNodeList != NULL)
	{
		pXMLDomNodeList->get_length(&n);
		pXMLDomNodeList->Release();
	}
	return n;
}
/*
	Function name	: CXML::GetRootNode
	Description	    : This helper function retrieves the DOM pointer to the root node
	Return type		: bool 
	Argument        : CString csRootTagName
	Tested			: Ok
*/
bool CXML::GetRootNode(CString csRootTagName)
{
	IXMLDOMNodeList * pINodeList = NULL;

	_bstr_t bstrRootTagName(csRootTagName);

	m_hr = m_pXMLDoc->getElementsByTagName(bstrRootTagName ,&pINodeList);

	if(!SUCCEEDED(m_hr))
		return false;

	m_hr = pINodeList->nextNode(&m_pIRootNode);
	pINodeList->Release();
	if(!SUCCEEDED(m_hr))
		return false;

	return true;
}
CXmlNodeList* CXmlNode::GetChildNodes()
{    
    if (NULL == m_pChildNodes && NULL != m_pNode)
    {
        HRESULT hr = S_OK;
        IXMLDOMNodeList* pChildNodes = NULL;

        hr = m_pNode->get_childNodes(&pChildNodes);
        if (SUCCEEDED(hr) && NULL != pChildNodes)
        {
            m_pChildNodes = new CXmlNodeList(pChildNodes);

            pChildNodes->Release();
            pChildNodes = NULL;
        }
    }

    return m_pChildNodes;
}
Exemple #8
0
HRESULT COFSNcDlg2::SelectChildNode(IXMLDOMNode *pNodeParent, BSTR bsSelect, IXMLDOMNode **ppNodeChild, BSTR *pbsNodeText)
{
	HRESULT hr;
	IXMLDOMNodeList *pNodeList = NULL;
	IXMLDOMNode *pNodeChild = NULL;
	
	if(pNodeParent == NULL || (ppNodeChild == NULL && pbsNodeText == NULL))
		return E_INVALIDARG;
	
	if(ppNodeChild != NULL)
		*ppNodeChild = NULL;
	
	DOMNodeType nt;
	hr = pNodeParent->get_nodeType(&nt);
	hr = pNodeParent->selectNodes(bsSelect, &pNodeList);
	if(pNodeList)
	{
		hr = pNodeList->get_item(0, &pNodeChild);
		if(pNodeChild != NULL)
		{
			if(pbsNodeText != NULL)
			{
				BSTR bs;
				hr = pNodeChild->get_text(&bs);
				*pbsNodeText = bs;
			}
			
			if(ppNodeChild == NULL)
			{
				pNodeChild->Release();
				pNodeChild = NULL;
			}
			else
				*ppNodeChild = pNodeChild;
		}
		pNodeList->Release();
		pNodeList = NULL;
	}
	return hr;
}
void lvDCOMInterface::getParams(std::map<std::string,std::string>& res)
{
	res.clear();
	char control_name_xpath[MAX_PATH_LEN];
	_snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param", m_configSection.c_str());
	IXMLDOMNodeList* pXMLDomNodeList = NULL;
	HRESULT hr = m_pxmldom->selectNodes(_bstr_t(control_name_xpath), &pXMLDomNodeList);
	if (FAILED(hr) || pXMLDomNodeList == NULL)
	{
		return;
	}
	IXMLDOMNode *pNode, *pAttrNode1, *pAttrNode2;
	long n = 0;
	pXMLDomNodeList->get_length(&n);
	for(long i=0; i<n; ++i)
	{
		pNode = NULL;
		hr = pXMLDomNodeList->get_item(i, &pNode);
		if (SUCCEEDED(hr) && pNode != NULL)
		{
			IXMLDOMNamedNodeMap *attributeMap = NULL;
			pAttrNode1 = pAttrNode2 = NULL;
			pNode->get_attributes(&attributeMap);
			hr = attributeMap->getNamedItem(_bstr_t("name"), &pAttrNode1);
			hr = attributeMap->getNamedItem(_bstr_t("type"), &pAttrNode2);
			BSTR bstrValue1 = NULL, bstrValue2 = NULL;
			hr=pAttrNode1->get_text(&bstrValue1);
			hr=pAttrNode2->get_text(&bstrValue2);
			res[std::string(COLE2CT(bstrValue1))] = COLE2CT(bstrValue2);
			SysFreeString(bstrValue1);
			SysFreeString(bstrValue2);
			pAttrNode1->Release();
			pAttrNode2->Release();
			attributeMap->Release();
			pNode->Release();
		}
	}	
	pXMLDomNodeList->Release();
}
Exemple #10
0
/** 
 * получение подузла по его имени
 * @param NodeName имя искомого узла
 * @param pIDOMNode дескриптор родительского узла
 * @return дескриптор нужного узла, или NULL в случае неудачи
 * @see ConfGetListNodeByName()  
 * @see ConfGetNodeText() 
 * @see ConfGetTextByName()
 */
IXMLDOMNode * ConfGetNodeByName(BSTR NodeName, IXMLDOMNode *pIDOMNode)
{
    IXMLDOMNode *pIDOMRetNode = NULL;
    IXMLDOMNodeList *pIDOMNodeList = NULL;

    if (pIDOMNode == NULL)
    {
        return NULL;
    }

    HRESULT hr = pIDOMNode->get_childNodes(&pIDOMNodeList);
    if (SUCCEEDED(hr) && pIDOMNodeList)
    {
        pIDOMRetNode = ConfGetListNodeByName(NodeName, pIDOMNodeList);
        pIDOMNodeList->Release();        
    } 
    else 
    {
        DbgMsg(__FILE__, __LINE__, "pIDOMNodeList->get_length() ERROR 0x%.8x\n", hr);
    }

    return pIDOMRetNode;
} 
void Explorerplusplus::LoadDialogStatesFromXML(IXMLDOMDocument *pXMLDom)
{
	IXMLDOMNodeList		*pNodes = NULL;
	IXMLDOMNode			*pNode = NULL;
	IXMLDOMNamedNodeMap	*am = NULL;
	IXMLDOMNode			*pChildNode = NULL;
	BSTR						bstrName;
	BSTR						bstrValue;
	BSTR						bstr = NULL;
	HRESULT						hr;
	long						length;
	long						lChildNodes;

	if(pXMLDom == NULL)
		goto clean;

	TCHAR tempNodeSelector[64];
	StringCchPrintf(tempNodeSelector, SIZEOF_ARRAY(tempNodeSelector),
		_T("//%s/*"), DIALOGS_XML_KEY);
	bstr = SysAllocString(tempNodeSelector);
	pXMLDom->selectNodes(bstr,&pNodes);

	if(!pNodes)
	{
		goto clean;
	}
	else
	{
		pNodes->get_length(&length);

		for(long i = 0;i < length;i++)
		{
			/* This should never fail, as the number
			of nodes has already been counted (so
			they must exist). */
			hr = pNodes->get_item(i,&pNode);

			if(SUCCEEDED(hr))
			{
				hr = pNode->get_attributes(&am);

				if(SUCCEEDED(hr))
				{
					/* Retrieve the total number of attributes
					attached to this node. */
					am->get_length(&lChildNodes);

					if(lChildNodes >= 1)
					{
						am->get_item(0,&pChildNode);

						pChildNode->get_nodeName(&bstrName);
						pChildNode->get_text(&bstrValue);

						for(CDialogSettings *ds : DIALOG_SETTINGS)
						{
							TCHAR settingsKey[64];
							bool success = ds->GetSettingsKey(settingsKey, SIZEOF_ARRAY(settingsKey));
							assert(success);

							if(!success)
							{
								continue;
							}

							if(lstrcmpi(bstrValue, settingsKey) == 0)
							{
								ds->LoadXMLSettings(am, lChildNodes);
							}
						}
					}
				}
			}

			pNode->Release();
			pNode = NULL;
		}
	}

clean:
	if (bstr) SysFreeString(bstr);
	if (pNodes) pNodes->Release();
	if (pNode) pNode->Release();
}
Exemple #12
0
bool TextTable::InitializeFromXmlDoc(XMLDoc* pXmlDoc, WCHAR* pwszFileName, bool bReload)
{
	if (NULL == pXmlDoc)
	{
		return false;
	}

	BSTR rowXPathFormat;
	rowXPathFormat = ::SysAllocString(L"/dataroot/%s/F%d");
	WCHAR wszXPath[MAX_UNICODE_XPATH_LENGTH + 1];

	DWORD dwSheetIndex = 0;
	WCHAR** ppwszSheetList = GetSheetListInWChar();

	BSTR bstr = NULL;

	while (ppwszSheetList[dwSheetIndex])
	{
		swprintf_s<_countof(wszXPath)>(wszXPath, rowXPathFormat, ppwszSheetList[dwSheetIndex], m_nField);

		IXMLDOMNodeList* pIndexNodeList = NULL;
		pIndexNodeList = pXmlDoc->SelectNodeList(wszXPath);
		if (!pIndexNodeList)
		{
			::SysFreeString(rowXPathFormat);

			return false;
		}

		LONG nIndexLength = 0;
		if (FAILED(pIndexNodeList->get_length(&nIndexLength)))
		{
			pIndexNodeList->Release();
			::SysFreeString(rowXPathFormat);

			return false;
		}

		swprintf_s<_countof(wszXPath)>(wszXPath, rowXPathFormat, ppwszSheetList[dwSheetIndex], m_nField + 1);

		IXMLDOMNodeList* pTextNodeList = NULL;
		pTextNodeList = pXmlDoc->SelectNodeList(wszXPath);
		if (!pTextNodeList)
		{
			pIndexNodeList->Release();
			::SysFreeString(rowXPathFormat);

			return false;
		}

		LONG nTextLength = 0;
		if (FAILED(pTextNodeList->get_length(&nTextLength)))
		{
			pIndexNodeList->Release();
			pTextNodeList->Release();
			::SysFreeString(rowXPathFormat);

			return false;
		}

		if (nTextLength != nIndexLength)
		{
			pIndexNodeList->Release();
			pTextNodeList->Release();
			::SysFreeString(rowXPathFormat);

			return false;
		}

		// 제목은 버린다.
		for (INT j = 1; j < nIndexLength; ++j)
		{
			VOID* pvTable = AllocNewTable(ppwszSheetList[dwSheetIndex], m_dwCodePage);
			if (!pvTable)
			{
				pIndexNodeList->Release();
				pTextNodeList->Release();
				::SysFreeString(rowXPathFormat);

				return false;
			}

			IXMLDOMNode* pCellNode = NULL;
			IXMLDOMNode* pDataNode = NULL;

			if (FAILED(pIndexNodeList->get_item(j, &pCellNode)))
			{
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			if (!pCellNode)
			{
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				break;
			}

			if (FAILED(pCellNode->get_firstChild(&pDataNode)))
			{
				pCellNode->Release();
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			if (!pDataNode)
			{
				pCellNode->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				break;
			}

			if (FAILED(pDataNode->get_text(&bstr)))
			{
				::SysFreeString(bstr);
				pDataNode->Release();
				pCellNode->Release();
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			SetTableData(pvTable, ppwszSheetList[dwSheetIndex], INDEX, bstr);

			::SysFreeString(bstr);
			pCellNode->Release();
			pDataNode->Release();

			pCellNode = NULL;
			pDataNode = NULL;

			if (FAILED(pTextNodeList->get_item(j, &pCellNode)))
			{
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			if (!pCellNode)
			{
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				break;
			}

			if (FAILED(pCellNode->get_firstChild(&pDataNode)))
			{
				//- yoshiki : TODO!(Get the field name)
				Table::CallErrorCallbackFunction("[File] : %S\n[Error] : Table data is null.(Row Index : %d, Field Name = %S)", pwszFileName, j - 1, L"FIELD_NAME!");

				pCellNode->Release();
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			if (!pDataNode)
			{
				//- yoshiki : TODO!(Get the field name)
				Table::CallErrorCallbackFunction("[File] : %S\n[Error] : Table data is null.(Row Index : %d, Field Name = %S)", pwszFileName, j - 1, L"FIELD_NAME!");

				pCellNode->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				_ASSERT(0);		// Index는 있고 Data는 공란인경우.
				break;
			}

			if (FAILED(pDataNode->get_text(&bstr)))
			{
				::SysFreeString(bstr);
				pDataNode->Release();
				pCellNode->Release();
				pIndexNodeList->Release();
				pTextNodeList->Release();
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
				::SysFreeString(rowXPathFormat);

				return false;
			}

			SetTableData(pvTable, ppwszSheetList[dwSheetIndex], TEXT, bstr);

			::SysFreeString(bstr);
			pCellNode->Release();
			pDataNode->Release();

			if (!AddTable(pvTable, bReload))
			{
				DeallocNewTable(pvTable, ppwszSheetList[dwSheetIndex]);
			}
		}

		pIndexNodeList->Release();
		pTextNodeList->Release();
		++dwSheetIndex;
	}

	::SysFreeString(rowXPathFormat);

	return true;
}
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();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}
		pResultStatusNote->Release();

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

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

			throw Exception(bstrResultMessage.m_str);
		}

		pResultChildren->Release();
		pResultNote->Release();

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

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

		long ItemCount = 0;
		pItemChildren->get_length(&ItemCount);
		if(hr != S_OK)
		{
			pItemChildren->Release();
			pItemNote->Release();
			pRootChildren->Release();
			pRoot->Release();
			pNodeList->Release();
			pDOM->Release();
			throw Exception(TEXT("解析视频分类数据失败。"));
		}

		for(int i=0; i<ItemCount; ++i)
		{
			IXMLDOMNode* pCatalogItemNote = NULL;
			hr = pItemChildren->get_item(i, &pCatalogItemNote);
			if(hr != S_OK)
			{
				pItemChildren->Release();
				pItemNote->Release();
				pRootChildren->Release();
				pRoot->Release();
				pNodeList->Release();
				pDOM->Release();
				throw Exception(TEXT("解析视频分类数据失败。"));
			}

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

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

			CComBSTR bstrCatalogId;
			hr = pCatalogIdNote->get_text(&bstrCatalogId);
			if(hr != S_OK)
			{
				pCatalogIdNote->Release();
				pCatalogItemChildren->Release();
				pCatalogItemNote->Release();
				pItemChildren->Release();
				pItemNote->Release();
				pRootChildren->Release();
				pRoot->Release();
				pNodeList->Release();
				pDOM->Release();
				throw Exception(TEXT("解析视频分类数据失败。"));
			}
			pCatalogIdNote->Release();

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

			pCatalogItemChildren->Release();
			pCatalogItemNote->Release();

			TSTLSTRING strCurrID = TSTLSTRING(COLE2T(bstrCatalogId));

			TSTLSTRING strLastCatalog = ConfigureManager::GetInstance().GetLastCatalog();
			TSTLSTRING strCurrName = TSTLSTRING(COLE2T(bstrCatalogName));
			bool IsSelected = ((strLastCatalog.empty() && strCurrName == TEXT("其他")) ||
				(!strLastCatalog.empty() && strLastCatalog.compare(strCurrID) == 0));

			strCatalogHtml.append(TEXT("<div class=\"ComboxListItem\" onmouseover=\"this.className='ComboxListItemSelected';\" onclick=\"OnCatalogComboxClick();\" onmouseout=\"this.className='ComboxListItem';\" Value=\""));
			strCatalogHtml.append(strCurrID);
			strCatalogHtml.append(TEXT("\">"));
			strCatalogHtml.append(strCurrName);
			strCatalogHtml.append(TEXT("</div>"));

			if(IsSelected)
				iSelectedIndex = i;
		}

		pItemChildren->Release();
		pItemNote->Release();

		pRootChildren->Release();
		pRoot->Release();
		pNodeList->Release();
		pDOM->Release();

		DISPPARAMS dp;
		memset(&dp, 0, sizeof(DISPPARAMS));
		dp.cArgs = 2;
		dp.cNamedArgs = 0;

		VARIANTARG arg[2];
		memset(arg, 0, sizeof(VARIANTARG) * 2);
		dp.rgvarg = arg;

		CComBSTR bstr(strCatalogHtml.c_str());
		arg[0].vt = VT_BSTR;
		bstr.CopyTo(&arg[0].bstrVal);
		arg[1].vt = VT_INT;
		arg[1].intVal = iSelectedIndex;

		m_lpCatalogInvoke->Invoke(
			0, 
			IID_NULL, 
			LOCALE_SYSTEM_DEFAULT,
			DISPATCH_METHOD,
			&dp,
			NULL, NULL, NULL);

	}
	catch(Exception& error)
	{
		MessageBox(error.GetMessage().c_str(), TEXT("错误"), MB_OK|MB_ICONERROR);
	}

	return 0;
}
string CKADmerge::GetPatternString(IXMLDOMNode * pXMLNode, BOOL bQuery)
{
    HRESULT hRes = 0;
    string sPatternString = "";
    string sElementName;

    if(pXMLNode)
    {
        // retrieve node name
        sElementName = GetName(pXMLNode);
        sPatternString = sElementName;

        if(SUCCEEDED(hRes))
        {
            // retrieve all attributes
            IXMLDOMNodeList * pNodeList = NULL;
            BSTR bPatternString = NULL;
            bPatternString = ::SysAllocString(L"@*");
            _bstr_t b2PatternString(bPatternString);
            hRes = pXMLNode->selectNodes(bPatternString, &pNodeList);
            ::SysFreeString(bPatternString);

            LONG lListLength = 0;
            hRes = pNodeList->get_length(&lListLength);

            if(SUCCEEDED(hRes) && lListLength)
            {
                // retrive attribute names
                IXMLDOMNode * pCurrentNode = NULL;
                hRes = pNodeList->nextNode(&pCurrentNode);
                string sAttributeName;
                while(pCurrentNode != NULL)
                {
                    // attach attibute names and values to pattern string
                    sAttributeName = GetName(pCurrentNode);

                    if(!bQuery)
                    {
                        // all attributes
                        if(sPatternString.find("[") == -1)
                        {
                            sPatternString += "[";
                        }
                        else
                        {
                            sPatternString += " and " ;
                        }
                        sPatternString += "@" + sAttributeName;
                        sPatternString += "=\"" + ExpandBackslash(GetValue(pCurrentNode)) + "\"";
                    }
                    else
                    {
                        // just "primary key" (only first attribute)
                        if(sPatternString.find("[") == -1)
                        {
                            sPatternString += "[";
                        }
                        sPatternString += "@" + sAttributeName;
                        sPatternString += "=\"" + ExpandBackslash(GetValue(pCurrentNode)) + "\"";

                        break;
                    }
                    hRes = pNodeList->nextNode(&pCurrentNode);
                }
                if(sPatternString.find("[") != -1)
                {
                    sPatternString += "]";
                }
            }
            if(pNodeList)
                pNodeList->Release();
        }
    }

    return sPatternString;
}
bool CModelToolCharDataTable::LoadProperty(const char * lpszFullPathFileName)
{
	CNtlXMLDoc doc;
	if(doc.Create() == false)
	{
		_ASSERT(0);
		return false;
	}
	
	if(doc.Load( const_cast<char *>(lpszFullPathFileName) ) == false)
	{
		_ASSERT(0);
		return false;
	}
	
	char szBuffer[1024];

	if( !doc.GetDataWithXPath(const_cast<char *>(XML_PROP_NAME_ATTRIBUTE), szBuffer, sizeof(szBuffer)) )
	{
		_ASSERT(0);
		return false;
	}

	sMODELTOOL_CHAR_TBLDAT	*pModelToolCharData = new sMODELTOOL_CHAR_TBLDAT;

	Add(szBuffer, pModelToolCharData);

	IXMLDOMNodeList *pAnimDataList = doc.SelectNodeList(XML_PROP_ANIM_DATA_ELEMENT);
	IXMLDOMNode* pAnimDataNode = NULL;

	IXMLDOMNodeList *pAnimEventList = NULL;
	IXMLDOMNode* pAnimEventNode = NULL;

	long	lAnimDataNodeNum = 0;
	long	lAnimEventNodeNum = 0;

	int		nAnimKeyID = 0;
	float	fDurationTime = 0.f;

	BYTE	byPushCount = 0;
	BYTE	byKnockDownCount = 0;
    bool    bKB2Push = false;
	BYTE	byHitCount = 0;
	float	aHitTime[NTL_MAX_SIZE_HIT];

	pAnimDataList->get_length(&lAnimDataNodeNum);
	for(long m = 0; m < lAnimDataNodeNum ; ++m)
	{
		pAnimDataList->get_item(m,&pAnimDataNode);

		if(!doc.GetTextWithAttributeName(pAnimDataNode, XML_PROP_ANIM_DATA_ELEMENT_KEYID_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
		{
			_ASSERT(0);
			return false;
		}
		nAnimKeyID = atoi(szBuffer);

		if(!doc.GetTextWithAttributeName(pAnimDataNode, XML_PROP_ANIM_DATA_ELEMENT_PLAYTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
		{
			_ASSERT(0);
			return false;
		}

		fDurationTime = (float)atof(szBuffer);
		
		pAnimDataNode->selectNodes(L"ANIM_EVENT", &pAnimEventList);
		pAnimEventList->get_length(&lAnimEventNodeNum);

		memset(aHitTime, 0, sizeof(aHitTime));
		for(long n = 0; n < lAnimEventNodeNum; ++n)
		{
			pAnimEventList->get_item(n, &pAnimEventNode);

			if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_EVENTID_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
			{
				_ASSERT(0);
				return false;
			}
	
			int nAnimEventID = EVENT_ANIM_NONE;
			int nBehavior = TARGET_BEHAVIOR_NONE;

			nAnimEventID = atoi(szBuffer);

			if(nAnimEventID == EVENT_ANIM_HIT)
			{
				if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITBEHAVIOR_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
				{
					_ASSERT(0);
					return false;
				}
				
				nBehavior = atoi(szBuffer);

				if(nBehavior == TARGET_BEHAVIOR_PUSH)
				{
					byPushCount++;
				}
				else if(nBehavior == TARGET_BEHAVIOR_KNOCK_DOWN)
				{
					byKnockDownCount++;
					if( byKnockDownCount > 1 )
					{
						_ASSERT(0);
						return false;
					}
				}

				// Hit time
				if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
				{
					_ASSERT(0);
					return false;
				}

				aHitTime[byHitCount] = (float)atof(szBuffer);
				byHitCount++;

				if(byHitCount > NTL_MAX_SIZE_HIT)
					_ASSERT(0);


				// KB2PUSH
				if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITKB2PUSH_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
				{
					_ASSERT(0);
					return false;
				}

				if(atoi(szBuffer) == 0)
				{
					bKB2Push = false;
				}
				else
				{
					bKB2Push = true;
				}
			}
            else if(nAnimEventID == EVENT_ANIM_SKILL_CANCEL)
            {
                // time
                if(!doc.GetTextWithAttributeName(pAnimEventNode, XML_PROP_ANIM_DATA_ELEMENT_HITTIME_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
                {
                    _ASSERT(0);
                    return false;
                }

                pModelToolCharData->AddSkillCancelTime(nAnimKeyID, (float)atof(szBuffer));
            }
			
			if(pAnimEventNode)
			{
				pAnimEventNode->Release();
				pAnimEventNode = NULL;
			}
		}

		if( nAnimKeyID != -1 )
			pModelToolCharData->Add(nAnimKeyID, fDurationTime, byPushCount, byKnockDownCount, byHitCount, aHitTime, bKB2Push);

		nAnimKeyID = 0;
		fDurationTime = 0;
		byPushCount = 0;
		byKnockDownCount = 0;
		byHitCount = 0;

		if(pAnimEventList)
		{
			pAnimEventList->Release();
			pAnimEventList = NULL;
		}
		
		if(pAnimDataNode)
		{
			pAnimDataNode->Release(); 
			pAnimDataNode = NULL;
		}
	}

	//pModelToolCharData->GetChainAttack(PC_CLASS_HUMAN_FIGHTER, ITEM_TYPE_UNKNOWN, 6);
	if(pAnimDataList)
	{
		pAnimDataList->Release(); 
		pAnimDataList = NULL;
	}

	char *pTokenStart = NULL;
	char *pTokenEnd = NULL;
	char szToken[64];

	if( !doc.GetDataWithXPath("MODEL_SCRIPT/HEADER/ANIM_BBOX", szBuffer, sizeof(szBuffer)) )
	{
		_ASSERT(0);
		return false;
	}
	
	CNtlVector vTemp;
	pTokenStart = szBuffer;
	pTokenEnd = strstr( szBuffer, ";");
	strncpy_s(szToken, sizeof(szToken), pTokenStart, pTokenEnd - pTokenStart);
	vTemp.x = (float) atof(szToken);

	pTokenStart = pTokenEnd + 1;
	pTokenEnd = strstr( pTokenStart, ";");
	strncpy_s(szToken, sizeof(szToken), pTokenStart, pTokenEnd - pTokenStart);
	vTemp.y = (float) atof(szToken);

	pTokenStart = pTokenEnd + 1;
	strncpy_s(szToken, sizeof(szToken), pTokenStart, strlen(szBuffer));
	vTemp.z = (float) atof(szToken);

	pModelToolCharData->m_vMin.x = -(vTemp.x / 2.0f);
	pModelToolCharData->m_vMin.y = 0.0f;
	pModelToolCharData->m_vMin.z = -(vTemp.z / 2.0f);
	
	pModelToolCharData->m_vMax.x = vTemp.x / 2.0f;
	pModelToolCharData->m_vMax.y = vTemp.y;
	pModelToolCharData->m_vMax.z = vTemp.z / 2.0f;

	if( !doc.GetDataWithXPath("MODEL_SCRIPT/BONE_DATA/BASE_SCALE", szBuffer, sizeof(szBuffer)) )
	{
		_ASSERT(0);
		return false;
	}

	pModelToolCharData->m_fScale = (float) atof(szBuffer);
	
	return true;
}
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();
	}
}
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;
	
}
Exemple #18
0
// эта функция, если значения нет (или тип некорректный) *value НЕ трогает
bool SettingsXML::Load(const wchar_t *regName, wchar_t **value)
{
	bool lbRc = false;
	HRESULT hr = S_OK;
	IXMLDOMNode* pChild = NULL;
	IXMLDOMNamedNodeMap* pAttrs = NULL;
	IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
	IXMLDOMNode *pNode = NULL;
	IXMLDOMNodeList* pList = NULL;
	BSTR bsType = NULL;
	BSTR bsData = NULL;
	size_t nLen = 0;

	//if (*value) {free(*value); *value = NULL;}

	if (mp_Key)
		pChild = FindItem(mp_Key, L"value", regName, false);

	if (!pChild)
		return false;

	hr = pChild->get_attributes(&pAttrs);

	if (SUCCEEDED(hr) && pAttrs)
	{
		bsType = GetAttr(pChild, pAttrs, L"type");
	}

	if (SUCCEEDED(hr) && bsType)
	{
		if (!lstrcmpi(bsType, L"multi"))
		{
			// Тут значения хранятся так:
			//<value name="CmdLineHistory" type="multi">
			//	<line data="C:\Far\Far.exe"/>
			//	<line data="cmd"/>
			//</value>
			wchar_t *pszData = NULL, *pszCur = NULL;
			size_t nMaxLen = 0, nCurLen = 0;
			long nCount = 0;

			if (pAttrs) { pAttrs->Release(); pAttrs = NULL; }

			// Получить все дочерние элементы нужного типа
			bsData = ::SysAllocString(L"line");
			hr = pChild->selectNodes(bsData, &pList);
			::SysFreeString(bsData); bsData = NULL;

			if (SUCCEEDED(hr) && pList)
			{
				hr = pList->get_length(&nCount);

				if (SUCCEEDED(hr) && (nCount > 0))
				{
					HEAPVAL;
					nMaxLen = ((MAX_PATH+1) * nCount) + 1;
					pszData = (wchar_t*)malloc(nMaxLen * sizeof(wchar_t));
					pszCur = pszData;
					pszCur[0] = 0; pszCur[1] = 0;
					nCurLen = 2; // сразу посчитать DoubleZero
					HEAPVAL;
				}
			}

			if (SUCCEEDED(hr) && pList)
			{
				hr = pList->reset();

				while ((hr = pList->nextNode(&pNode)) == S_OK && pNode)
				{
					bsData = GetAttr(pNode, L"data");
					pNode->Release(); pNode = NULL;

					if (SUCCEEDED(hr) && bsData)
					{
						nLen = _tcslen(bsData) + 1;

						if ((nCurLen + nLen) > nMaxLen)
						{
							// Нужно пересоздать!
							nMaxLen = nCurLen + nLen + MAX_PATH + 1;
							wchar_t *psz = (wchar_t*)malloc(nMaxLen * sizeof(wchar_t));
							_ASSERTE(psz);

							if (!psz) break;  // Не удалось выделить память!

							wmemmove(psz, pszData, nCurLen);
							pszCur = psz + (pszCur - pszData);
							HEAPVAL;
							free(pszData);
							pszData = psz;
							HEAPVAL;
						}

						lstrcpy(pszCur, bsData);
						pszCur += nLen; // указатель - на место для следующей строки
						nCurLen += nLen;
						*pszCur = 0; // ASCIIZZ
						HEAPVAL;
						::SysFreeString(bsData); bsData = NULL;
					}
				}

				pList->Release(); pList = NULL;
			}

			// значит что-то прочитать удалось
			if (pszData)
			{
				if (*value) {free(*value); *value = NULL;}
				*value = pszData;
				lbRc = true;
			}
		}
		else if (!lstrcmpi(bsType, L"string"))
		{
			bsData = GetAttr(pChild, pAttrs, L"data");

			if (SUCCEEDED(hr) && bsData)
			{
				nLen = _tcslen(bsData);
				if (!*value || (_tcslen(*value) <= nLen))
				{
					*value = (wchar_t*)realloc(*value, (nLen+2)*sizeof(wchar_t));
				}
				if (*value)
				{
					lstrcpy(*value, bsData);
					(*value)[nLen] = 0; // уже должен быть после lstrcpy
					(*value)[nLen+1] = 0; // ASCIIZZ
					lbRc = true;
				}
			}
		}

		// Все остальные типы - не интересуют. Нам нужны только строки
	}

	if (bsType) { ::SysFreeString(bsType); bsType = NULL; }

	if (bsData) { ::SysFreeString(bsData); bsData = NULL; }

	if (pChild) { pChild->Release(); pChild = NULL; }

	if (pAttrs) { pAttrs->Release(); pAttrs = NULL; }

	//if (!lbRc)
	//{
	//	_ASSERTE(*value == NULL);
	//	*value = (wchar_t*)malloc(sizeof(wchar_t)*2);
	//	(*value)[0] = 0; (*value)[1] = 0; // На случай REG_MULTI_SZ
	//}

	return lbRc;
}
Exemple #19
0
IXMLDOMNode* SettingsXML::FindItem(IXMLDOMNode* apFrom, const wchar_t* asType, const wchar_t* asName, bool abAllowCreate)
{
	HRESULT hr = S_OK;
	IXMLDOMNodeList* pList = NULL;
	IXMLDOMNode* pChild = NULL;
	IXMLDOMNamedNodeMap* pAttrs = NULL;
	IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
	IXMLDOMNode *pIXMLDOMNode = NULL;
	IXMLDOMNode *pName = NULL;
	BSTR bsText = NULL;
	BSTR bsCheck = NULL;
	DOMNodeType nodeTypeCheck = NODE_INVALID;
	BOOL lbEmpty = TRUE;
	int iLastIndent = 1;

	// Получить все дочерние элементы нужного типа
	if (apFrom == NULL)
	{
		hr = S_FALSE;
	}
	else
	{
		long lFound = 0;
		// key[@name="abc"], but it is case-sensitive, and may fails in theory
		bsText = lstrmerge(asType, L"[@name=\"", asName, L"\"]");
		hr = apFrom->selectNodes(bsText, &pList);
		if (SUCCEEDED(hr) && pList)
		{
			hr = pList->get_length(&lFound);
			if (FAILED(hr) || (lFound < 1))
			{
				SafeRelease(pList);
			}
		}
		SafeFree(bsText);
		// May be case-insensitive search will be succeeded?
		// However, it is very slow
		if (!pList)
		{
			bsText = ::SysAllocString(asType);
			hr = apFrom->selectNodes(bsText, &pList);
			::SysFreeString(bsText); bsText = NULL;
		}
	}

	if (SUCCEEDED(hr) && pList)
	{
		hr = pList->reset();

		while ((hr = pList->nextNode(&pIXMLDOMNode)) == S_OK && pIXMLDOMNode)
		{
			lbEmpty = FALSE;
			hr = pIXMLDOMNode->get_attributes(&pAttrs);

			if (SUCCEEDED(hr) && pAttrs)
			{
				bsText = GetAttr(pIXMLDOMNode, pAttrs, L"name");

				if (bsText)
				{
					if (lstrcmpi(bsText, asName) == 0)
					{
						::SysFreeString(bsText); bsText = NULL;
						pChild = pIXMLDOMNode; pIXMLDOMNode = NULL;
						break;
					}

					::SysFreeString(bsText); bsText = NULL;
				}
			}

			pIXMLDOMNode->Release(); pIXMLDOMNode = NULL;
		}

		pList->Release();
		//pList = NULL; -- для отладки
	}

	if (lbEmpty && abAllowCreate && (asType[0] == L'k'))
	{
		bsText = ::SysAllocString(L"value");
		hr = apFrom->selectNodes(bsText, &pList);
		::SysFreeString(bsText); bsText = NULL;
		if (SUCCEEDED(hr) && pList)
		{
			hr = pList->reset();
			if ((hr = pList->nextNode(&pIXMLDOMNode)) == S_OK && pIXMLDOMNode)
			{
				lbEmpty = FALSE;
				pIXMLDOMNode->Release(); pIXMLDOMNode = NULL;
			}
			pList->Release();
			//pList = NULL; -- для отладки
		}
	}

	if (!pChild && abAllowCreate)
	{
		if (asType[0] == L'k')
		{
			hr = apFrom->get_lastChild(&pChild);
			if (SUCCEEDED(hr) && pChild)
			{
				hr = pChild->get_nodeType(&nodeTypeCheck);
				if (SUCCEEDED(hr) && (nodeTypeCheck == NODE_TEXT))
				{
					hr = pChild->get_text(&bsCheck);
					if (SUCCEEDED(hr) && bsCheck)
					{
						iLastIndent = 0;
						LPCWSTR pszTabs = bsCheck;
						while (*pszTabs)
						{
							if (*(pszTabs++) == L'\t')
								iLastIndent++;
						}
						::SysFreeString(bsCheck); bsCheck = NULL;
					}
				}
			}
			SafeRelease(pChild);
		}

		VARIANT vtType; vtType.vt = VT_I4;
		vtType.lVal = NODE_ELEMENT;
		bsText = ::SysAllocString(asType);
		hr = mp_File->createNode(vtType, bsText, L"", &pChild);
		::SysFreeString(bsText); bsText = NULL;

		if (SUCCEEDED(hr) && pChild)
		{
			if (SetAttr(pChild, L"name", asName))
			{
				if (asType[0] == L'k')
				{
					AppendNewLine(pChild);
					mb_KeyEmpty = true;
					TouchKey(pChild);
				}

				if (asType[0] == L'k')
				{
					//if (mb_KeyEmpty)
					//AppendIndent(apFrom, lbEmpty ? (mi_Level-1) : mi_Level);
					AppendIndent(apFrom, (mi_Level-iLastIndent));
				}
				else if (mb_KeyEmpty)
				{
					AppendIndent(apFrom, !lbEmpty ? (mi_Level-1) : mi_Level);
				}
				else
				{
					AppendIndent(apFrom, 1);
				}
				hr = apFrom->appendChild(pChild, &pIXMLDOMNode);
				pChild->Release(); pChild = NULL;

				if (FAILED(hr))
				{
					pAttrs->Release(); pAttrs = NULL;
				}
				else
				{
					pChild = pIXMLDOMNode;
					pIXMLDOMNode = NULL;
				}

				AppendNewLine(apFrom);
				AppendIndent(apFrom, mi_Level-1);
				if ((asType[0] != L'k') && mb_KeyEmpty)
					mb_KeyEmpty = false;
			}
			else
			{
				pChild->Release(); pChild = NULL;
			}
		}
	}

	return pChild;
}
bool CModelToolCharDataTable::LoadPropertyList(const char *lpszPath, const char * lpszFileName)
{
	CNtlXMLDoc doc;
	std::string strPath( lpszPath );
	std::string strFileName;
	
	if(doc.Create() == false)
	{
		_ASSERT(0);
		return false;
	}
	
	strFileName = strPath;
	strFileName += "/";
	strFileName += lpszFileName;

	if(doc.Load( const_cast<char *>(strFileName.c_str()) ) == false)
	{
		_ASSERT(0);
		return false;
	}
	
	

	IXMLDOMNodeList *pList = doc.SelectNodeList(XML_PROP_LIST_ELEMENT);
	IXMLDOMNode* pNode = NULL;
	char szBuffer[1024];

	long  lNum;
	pList->get_length(&lNum);
	for(long i = 0; i < lNum ; ++i)
	{
		pList->get_item(i,&pNode);

		if(!doc.GetTextWithAttributeName(pNode, XML_PROP_LIST_ELEMENT_NAME_ATTRIBUTE, szBuffer, sizeof(szBuffer)))
		{
			_ASSERT(0);
			return false;
		}
		strFileName = strPath + "/" + szBuffer;
		
		if( LoadProperty( strFileName.c_str() ) == false )
		{
			_ASSERT(0);
			return false;
		}

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

	if(pList)
	{
		pList->Release(); 
		pList = NULL;
	}

	return true;
}
///////////////////////////////////////////////////////
// RADEventsXML::ProcessEvents
//
// Method to process a list of events, either transforming XML
// into RADEvents, or RADEvents into XML event nodes.
// Invoked by the Populate and Persist methods.
//
// When transforming the RADEvent objects on the list 'rel' into
// XML Event nodes, a new XML Event node is created, and appended
// to the XML Events node of the XML document.
// 
// When transforming the XML Events node with XML Event nodes, each
// XML Event node is transformed to a RADEvent object, and the RADEvent
// object is appended to the RADEventsList 'rel'.
//
// Input/Output:
//	rel	- the RADEventsList instance
//  bExtract - processing toggle:
//		When true, run through the XML event nodes, creating
//		RADEvent objects on 'rel'.
//		When false, run through the RADEvent objects, creating
//		XML event nodes on the XML document.
//
///////////////////////////////////////////////////////
bool RADEventsXML::ProcessEvents(RADEventsList& rel, bool bExtract)
{

	// if bExtract, we want to read the XML events and populate the list of event objects
	// first: get count of events nodes
	// second:
	//	for each event node
	//    get the node
	//    create a RADEvent, using the node attributes to populate it
	//	  insert the RADEvent object into the RADEventsList 'rel'
	// end
	// else, not bExtract, we want to transform the list of RADEvent objects into an XML document
	// for each RADEvent on the RADEventsList 'rel,
	//    create a new XML Event Node, using each stirng value as an attribute value
	//    append the XML Event node to the <IR/Events> node
	//  end

	HRESULT hr;
	_bstr_t xbstr = m_xirevsevpath;

	if (bExtract)  // converting from XML <Event> to RADEvent
	{
		IXMLDOMNodeList* pXMLDomNodeList = NULL;
		HRCALL(m_pXMLDom->selectNodes(xbstr, &pXMLDomNodeList), "selectNodes");
		if (pXMLDomNodeList)
		{
			long count = 0;
			HRCALL(pXMLDomNodeList->get_length(&count), "get_length");
			IXMLDOMNode *pEventNode=NULL;
			for (long i=0; i<count; i++)
			{
				HRCALL(pXMLDomNodeList->get_item(i, &pEventNode), "get_item: ");
				if (bDebug)
				{
					BSTR dbg1str;
					BSTR dbg2str;
					HRCALL(pEventNode->get_nodeName(&dbg1str), "get_nodeName: ");
					dprintf("Node (%d), <%S>:\n",i, static_cast<wchar_t*>(dbg1str));
					HRCALL(pEventNode->get_xml(&dbg2str), "get_xml: ");
					dprintf("\t%S\n",  static_cast<wchar_t*>(dbg2str));
				}

				RADEvent* p = XMLToEvent(pEventNode);
				rel.AddToEnd(p);
				if (bDebug)
				{
					dprintf(p->Image());
				}
				if (pEventNode) pEventNode->Release();
			}
			pXMLDomNodeList->Release();
		}
		else
		{
			ReportParseError(m_pXMLDom, "Error while calling ProcessEvents/selectNodes ");
		}
	}
	else // converting from RADEvent to XML <Event>
	{
		IXMLDOMElement * pE;
		IXMLDOMNode *pIXMLDOMNode = NULL;
		long i = 0;
		POSITION pos = rel.GetHeadPosition();
		while( pos != NULL )
		{
			RADEvent* p = (RADEvent*)rel.GetNext( pos );
			pE = ConstructEventNode(p);
			if (pE)
			{
				HRCALL(m_pIRNode->appendChild(pE,&pIXMLDOMNode), ""); 
				AddWhiteSpaceToNode(bstr_wsnt, m_pIRNode);
				i++;
			}
		}
	}

clean: 
	if (FAILED(hr))
		return false;
	else
		return true;
}
/*
	Function name	: CXML::ReplaceNodeText
	Description	    : This Helper function replaces the existing text with the given text of 
					: the given node. 
	Return type		: bool 
	Argument        : IXMLDOMNode **pNode
	Argument        : CString &rcsNodeText
	Tested			: 
*/
bool CXML::ReplaceNodeText(IXMLDOMNode **pNode,CString &rcsNodeText)
{
	IXMLDOMText  * pTextNode = NULL;
	if(!(*pNode))
		return false;

	IXMLDOMNode * pTempNode = NULL;
	DOMNodeType nodeType;
	IXMLDOMNode * pINewNode = NULL;
	IXMLDOMNode * pIOldNode = NULL;
	IXMLDOMNodeList * pChildList = NULL;
	long nLen = 0,i=0;


	_bstr_t bstrData(rcsNodeText);

	m_hr = m_pXMLDoc->createTextNode(bstrData,&pTextNode);
	if(!SUCCEEDED(m_hr) || !pTextNode)
		goto on_Error;	


	m_hr = (*pNode)->get_childNodes(&pChildList);
	if(!SUCCEEDED(m_hr) || !pChildList)
		goto on_Error;
	
	m_hr = pChildList->get_length(&nLen);
	if(!SUCCEEDED(m_hr))
		goto on_Error;

	if(nLen == 0)	// no childs, if the tag is empty
	{
		bool bRet = CreateNodeText(pNode,rcsNodeText);
		if(pChildList)
			pChildList->Release();
		if(pTextNode)
			pTextNode->Release();
		return bRet;		
	}

	for(i =0; i< nLen;++i)
	{
		m_hr = pChildList->nextNode(&pTempNode);
		if(!SUCCEEDED(m_hr))
			goto on_Error;

		m_hr = pTempNode->get_nodeType(&nodeType);
		if(!SUCCEEDED(m_hr))
			goto on_Error;

		if(nodeType == NODE_TEXT)
			break;

		if(pTempNode)
		{
			pTempNode->Release();
			pTempNode = NULL;
		}
	}

	m_hr = (*pNode)->replaceChild(pTextNode,pTempNode,&pINewNode);
	if(!SUCCEEDED(m_hr) || !pINewNode)
			goto on_Error;

	if(pChildList)
		pChildList->Release();
	if(pTextNode)
		pTextNode->Release();
	if(pINewNode)
		pINewNode->Release();
	if(pTempNode)
		pTempNode->Release();

	return true;


on_Error:	// Release all the References

	if(pChildList)
		pChildList->Release();
	if(pTextNode)
		pTextNode->Release();
	if(pINewNode)
		pINewNode->Release();
	if(pTempNode)
		pTempNode->Release();
	
	return false; 
}
HRESULT CKADmerge::GetKADFilenames(string * sFilenames[], LONG &lLength, string sLogFile)
{
    HRESULT hRes = S_FALSE;

    if(sLogFile != "")
    {
        // open log file
        OpenLog(sLogFile, sDescription + " GetKADFileNames");
    }

    IXMLDOMNode * pXMLRoot = NULL;
    hRes = GetRootElement(m_pXMLKad, &pXMLRoot);

    if(hRes == S_OK)
    {
        // find elements
        IXMLDOMNodeList * pElemList = NULL;
        _bstr_t bPatternString("/KAD4CE/KERNEL/ADDON[@KADFILE]");
        hRes = pXMLRoot->selectNodes(bPatternString, &pElemList);

        if(SUCCEEDED(hRes))
        {
            LONG lElements = 0;
            pElemList->get_length(&lElements);

            (*sFilenames) = new string[lElements];

            IXMLDOMNode * pCurrentElem = NULL;
            hRes = pElemList->nextNode(&pCurrentElem);
            int i = 0;
            while(pCurrentElem != NULL)
            {
                // find 'KADFILE' attribute
                IXMLDOMNodeList * pAttrList = NULL;
                _bstr_t bPatternString("@KADFILE");
                hRes = pCurrentElem->selectNodes(bPatternString, &pAttrList);

                if(SUCCEEDED(hRes))
                {
                    LONG lAtributes = 0;
                    pAttrList->get_length(&lAtributes);

                    IXMLDOMNode * pCurrentAttr = NULL;
                    hRes = pAttrList->nextNode(&pCurrentAttr);
                    if(lAtributes == 1)
                    {
                        (*sFilenames)[i++] = GetValue(pCurrentAttr);
                    }
                    if(pCurrentAttr)
                        pCurrentAttr->Release();
                }
                hRes = pElemList->nextNode(&pCurrentElem);
                if(pAttrList)
                    pAttrList->Release();
            }
            lLength = i;
            hRes = S_OK;

            if(pCurrentElem)
                pCurrentElem->Release();
        }

        if(pXMLRoot)
            pXMLRoot->Release();
        if(pElemList)
            pElemList->Release();
    }

    if(hRes == S_OK)
    {
        Log("GetKADFilenames:");
        for(int i = 0; i < (int)lLength; i++)
        {
            Log((*sFilenames)[i]);
        }
    }

    // close log file
    CloseLog();

    return hRes;
}
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);
							Segmentation_Penalty = _wtof(value.bstrVal);
							pAttrNode->Release();
						}

						pNodeMap->Release();
					}

					pParamNode->Release();
				}
			}
		}

		pDoc->Release();
	}

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

	return S_OK;
}
Exemple #25
0
IXMLDOMNode* SettingsXML::FindItem(IXMLDOMNode* apFrom, const wchar_t* asType, const wchar_t* asName, bool abAllowCreate)
{
	HRESULT hr = S_OK;
	IXMLDOMNodeList* pList = NULL;
	IXMLDOMNode* pChild = NULL;
	IXMLDOMNamedNodeMap* pAttrs = NULL;
	IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
	IXMLDOMNode *pIXMLDOMNode = NULL;
	IXMLDOMNode *pName = NULL;
	BSTR bsText = NULL;
	BOOL lbEmpty = TRUE;

	// Получить все дочерние элементы нужного типа
	if (apFrom == NULL)
	{
		hr = S_FALSE;
	}
	else
	{
		bsText = ::SysAllocString(asType);
		hr = apFrom->selectNodes(bsText, &pList);
		::SysFreeString(bsText); bsText = NULL;
	}

	if (SUCCEEDED(hr) && pList)
	{
		hr = pList->reset();

		while((hr = pList->nextNode(&pIXMLDOMNode)) == S_OK && pIXMLDOMNode)
		{
			lbEmpty = FALSE;
			hr = pIXMLDOMNode->get_attributes(&pAttrs);

			if (SUCCEEDED(hr) && pAttrs)
			{
				bsText = GetAttr(pIXMLDOMNode, pAttrs, L"name");

				if (bsText)
				{
					if (lstrcmpi(bsText, asName) == 0)
					{
						::SysFreeString(bsText); bsText = NULL;
						pChild = pIXMLDOMNode; pIXMLDOMNode = NULL;
						break;
					}

					::SysFreeString(bsText); bsText = NULL;
				}
			}

			pIXMLDOMNode->Release(); pIXMLDOMNode = NULL;
		}

		pList->Release();
		//pList = NULL; -- для отладки
	}
	
	if (lbEmpty && abAllowCreate && (asType[0] == L'k'))
	{
		bsText = ::SysAllocString(L"value");
		hr = apFrom->selectNodes(bsText, &pList);
		::SysFreeString(bsText); bsText = NULL;
		if (SUCCEEDED(hr) && pList)
		{
			hr = pList->reset();
			if ((hr = pList->nextNode(&pIXMLDOMNode)) == S_OK && pIXMLDOMNode)
			{
				lbEmpty = FALSE;
				pIXMLDOMNode->Release(); pIXMLDOMNode = NULL;
			}
			pList->Release();
			//pList = NULL; -- для отладки
		}
	}

	if (!pChild && abAllowCreate)
	{
		VARIANT vtType; vtType.vt = VT_I4;
		vtType.lVal = NODE_ELEMENT;
		bsText = ::SysAllocString(asType);
		hr = mp_File->createNode(vtType, bsText, L"", &pChild);
		::SysFreeString(bsText); bsText = NULL;

		if (SUCCEEDED(hr) && pChild)
		{
			if (SetAttr(pChild, L"name", asName))
			{
				if (asType[0] == L'k')
				{
					AppendNewLine(pChild);
					mb_KeyEmpty = true;
				}

				if (asType[0] == L'k')
				{
					//if (mb_KeyEmpty)
					//AppendIndent(apFrom, lbEmpty ? (mi_Level-1) : mi_Level);
					AppendIndent(apFrom, (mi_Level-1));
				}
				else if (mb_KeyEmpty)
				{
					AppendIndent(apFrom, !lbEmpty ? (mi_Level-1) : mi_Level);
				}
				else
				{
					AppendIndent(apFrom, 1);
				}
				hr = apFrom->appendChild(pChild, &pIXMLDOMNode);
				pChild->Release(); pChild = NULL;

				if (FAILED(hr))
				{
					pAttrs->Release(); pAttrs = NULL;
				}
				else
				{
					pChild = pIXMLDOMNode;
					pIXMLDOMNode = NULL;
				}

				AppendNewLine(apFrom);
				AppendIndent(apFrom, mi_Level-1);
				if ((asType[0] != L'k') && mb_KeyEmpty)
					mb_KeyEmpty = false;
			}
			else
			{
				pChild->Release(); pChild = NULL;
			}
		}
	}

	return pChild;
}