C++ &引用;“读取xml文件”;

C++ &引用;“读取xml文件”;,c++,mfc,msxml,C++,Mfc,Msxml,我正在加载和读取一个xml文件。我在使用VisualStudio6时是成功的,但现在我改成了VisualStudio10,并且没有编译 我正在使用MFC类开发SDI应用程序 以下是错误: 错误1120-,一个未解析的外部 未处理的异常 代码: CComPtr iRootElm; ::协同初始化(空); HRESULT hr=m_plDomDocument.CreateInstance(u uuidof(DOMDocument)); 如果(失败(小时)) { _通信错误er(hr); AfxMes

我正在加载和读取一个xml文件。我在使用VisualStudio6时是成功的,但现在我改成了VisualStudio10,并且没有编译

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

以下是错误:

  • 错误1120-,一个未解析的外部
  • 未处理的异常
  • 代码:

    CComPtr iRootElm;
    ::协同初始化(空);
    HRESULT hr=m_plDomDocument.CreateInstance(u uuidof(DOMDocument));
    如果(失败(小时))
    {
    _通信错误er(hr);
    AfxMessageBox(er.ErrorMessage());
    //结束对话(1);
    }
    CString strFileName(“TestCase.xml”);
    //将xml文件名字符串转换为COM可以处理的内容(BSTR)
    //fname=strFileName;
    _bstr_t bstrFileName;
    变量布尔*标志=NULL;
    bstrFileName=fname.AllocSysString();
    _变异源;
    source.vt=vt\u BSTR;
    source.bstrVal=bstrFileName;
    //变量源=(变量)fname;
    //调用IXMLDOMDocumentPtr的load函数来加载XML文档
    变异结果;
    //vResult=;
    vResult=m_plDomDocument->load(源,标志);
    bool v=(bool)vResult;
    if((bool)vResult==true)//成功!
    {
    //现在文档已经加载,我们需要初始化根指针
    //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(“文档加载成功!”);
    //AfxMessageBox(m_plDomDocument);
    }
    其他的
    {
    AfxMessageBox(_T(“文档加载失败!”);
    }
    }
    
    根据Visual studio帮助

    致命错误C1120

    此错误指示需要重新安装VisualC++。 :(

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