"Reading xml file"

"Reading xml file"

本文关键字:file Reading xml      更新时间:2023-10-16

我正在加载和读取xml文件。当我使用Visual studio 6时,我是成功的,但现在我已经更改为Visual studio 10,并且无法编译。

我正在使用MFC类开发SDI应用程序。

错误如下:

  1. 错误1120 -,一个未解决的外部
  2. <
  3. 未处理异常/gh>
代码:

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!"));  
    }
}

根据Visual studio帮助

致命错误C1120

此错误指示需要重新安装Visual c++。

: