I am loading and reading a xml file. I was successful when I was using Visual studio 6 but now I have changed to Visual studio 10 and does not compile.
I am developing SDI application using MFC classes.
This are the errors:
- error 1120 - , one unresolved externals
- unhandled exception
Code:
CComPtr<IXMLDOMElement> iRootElm;
::CoInitialize(NULL);
HRESULT hr = m_plDomDocument.CreateInstance(__uuidof(DOMDocument));
if (FAILED(hr))
{
_com_error er(hr);
AfxMessageBox(er.ErrorMessage());
//EndDialog(1);
}
CString strFileName ("TestCase.xml");
// convert xml file name string to something COM can handle (BSTR)
//fname = strFileName;
_bstr_t bstrFileName;
VARIANT_BOOL *flag = NULL;
bstrFileName = fname.AllocSysString();
_variant_t source;
source.vt = VT_BSTR;
source.bstrVal = bstrFileName;
//VARIANT source = (VARIANT)fname;
// call the IXMLDOMDocumentPtr's load function to load the XML document
variant_t vResult;
//vResult = ;
vResult = m_plDomDocument->load(source , flag);
bool v = (bool)vResult;
if ((bool)vResult == true) // success!
{
// now that the document is loaded, we need to initialize the root pointer
//m_pDocRoot = m_plDomDocument->createElement((_bstr_t)"TestCase" , temp); // ->documentElement;
m_pDocRoot = m_plDomDocument->get_documentElement(&iRootElm);
//m_pDocRoot = m_plDomDocument->createElement((_bstr_t)"TestCase.cml" );
AfxMessageBox(_T("Document loaded successfully!"));
//AfxMessageBox(m_plDomDocument);
}
else
{
AfxMessageBox(_T("Document FAILED to load!"));
}
}