MSXML2::IXMLDOMNodePtr CXmlBase::CreateRootNode(MSXML2::IXMLDOMDocument2Ptr pDoc
	, LPCTSTR lpszRootText)
{
	HRESULT hr = S_OK;
	MSXML2::IXMLDOMElementPtr pElement = NULL;
	MSXML2::IXMLDOMNodePtr pNode = NULL;
	CComBSTR bstrRootText = _bstr_t("root").GetBSTR();

	if (pDoc == NULL) return NULL;

	if (lpszRootText != NULL)
		bstrRootText = lpszRootText;

	if (bstrRootText.Length() == 0) return NULL;

	try
	{
		//hr = pDoc->raw_createElement(bstrRootText.m_str, &pElement);
		//if (FAILED(hr) || pElement == NULL) return NULL;
		//pNode = pElement;
		pNode = pDoc->createNode(NODE_ELEMENT, bstrRootText.m_str, _T(""));
		if (pNode == NULL) return NULL;
		//hr = pDoc->raw_appendChild(pNode, NULL);
		//if (FAILED(hr)) return NULL;
		pNode = pDoc->appendChild(pNode);
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml根节点发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox( NULL, str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pNode;
}
MSXML2::IXMLDOMNodePtr CXmlBase::CreateXmlTitle(MSXML2::IXMLDOMDocument2Ptr pDoc)
{
	MSXML2::IXMLDOMProcessingInstructionPtr pi = NULL;
	MSXML2::IXMLDOMNodePtr pNode = NULL;

	if (pDoc == NULL) return NULL;
	try
	{
		pi = pDoc->createProcessingInstruction(_T("xml")
			, _T("version=\"1.0\" encoding=\"UTF-8\""));
		if (pi == NULL) return NULL;
		
		pNode = pi;
		if (NULL == (pNode = pDoc->appendChild(pNode)))
		{
			pi.Release();
			pNode.Release();
			return NULL;
		}
		pi.Release();
		//pNode.Release();
	}
	catch(_com_error &e)
	{
		CString str;
		str.Format(_T("创建xml头发生异常。\r\nComError:\r\n%s")
			, e.ErrorMessage());
		::MessageBox( NULL,str, g_sAppTitle, MB_OK|MB_ICONERROR);
		return NULL;
	}
	catch(...)
	{
		return NULL;
	}
	return pNode;
}