EDN Admin
Well-known member
I have two xml files to do convert by using transformNodeToObject method.
The interesting things are:
It worked well with MSXML:OMDocument40 coclass, but MSXML:OMDocument60 will return a com error if I call transformNodeToObject method. The com error is E_FAIL.
===========================================
#import "msxml6.dll" rename_namespace("MSXML")<br/>
<br/>
int _tmain(int argc, _TCHAR* argv[])<br/>
{<br/>
::CoInitialize(NULL);<br/>
MSXML::IXMLDOMDocumentPtr pXslt;<br/>
HRESULT hr = pXslt.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
MSXML::IXMLDOMDocumentPtr pInputXml;<br/>
hr = pInputXml.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
pInputXml->load("I:\DC7\ECM00167159 mtd crash\tomfiles\Xml_Input.xml");<br/>
pXslt->load("I:\DC7\ECM00167159 mtd crash\tomfiles\Xml_Transform.xml");<br/>
<br/>
MSXML::IXMLDOMDocumentPtr pResultXml;<br/>
hr = pResultXml.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
CComVariant vtOutput((LPDISPATCH)pResultXml);<br/>
try{<br/>
hr = pInputXml->transformNodeToObject(pXslt, vtOutput);<br/>
}<br/>
catch(const _com_error &e)<br/>
{<br/>
long lError = pInputXml->parseError->errorCode;<br/>
_bstr_t bstrReason = pInputXml->parseError->reason;<br/>
int i = 0;<br/>
}<br/>
<br/>
::CoUninitialize();<br/>
<br/>
return 0;<br/>
}
View the full article
The interesting things are:
It worked well with MSXML:OMDocument40 coclass, but MSXML:OMDocument60 will return a com error if I call transformNodeToObject method. The com error is E_FAIL.
===========================================
#import "msxml6.dll" rename_namespace("MSXML")<br/>
<br/>
int _tmain(int argc, _TCHAR* argv[])<br/>
{<br/>
::CoInitialize(NULL);<br/>
MSXML::IXMLDOMDocumentPtr pXslt;<br/>
HRESULT hr = pXslt.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
MSXML::IXMLDOMDocumentPtr pInputXml;<br/>
hr = pInputXml.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
pInputXml->load("I:\DC7\ECM00167159 mtd crash\tomfiles\Xml_Input.xml");<br/>
pXslt->load("I:\DC7\ECM00167159 mtd crash\tomfiles\Xml_Transform.xml");<br/>
<br/>
MSXML::IXMLDOMDocumentPtr pResultXml;<br/>
hr = pResultXml.CreateInstance(__uuidof(MSXML:OMDocument40));<br/>
<br/>
CComVariant vtOutput((LPDISPATCH)pResultXml);<br/>
try{<br/>
hr = pInputXml->transformNodeToObject(pXslt, vtOutput);<br/>
}<br/>
catch(const _com_error &e)<br/>
{<br/>
long lError = pInputXml->parseError->errorCode;<br/>
_bstr_t bstrReason = pInputXml->parseError->reason;<br/>
int i = 0;<br/>
}<br/>
<br/>
::CoUninitialize();<br/>
<br/>
return 0;<br/>
}
View the full article