CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2002
    Posts
    12

    Question include msxml couse compilation error PLEASE HELP

    Hi.

    I'm spending too much time on this problem and yet have no results.

    My problem is a simple one.
    I want to use the xml parse, so I'm trying to add
    #include <msxml.h> to .h file in my dll project, so I can use the IXMLDOMsomething.
    But thane these compilation error are generated:

    error C2146: syntax error : missing ';' before identifier 'IXMLDOMImplementation'

    fatal error C1004: unexpected end of file found

    Without this #include there is no compilation error at all. So it's not a problem in my code like "#ifndef #endif problem which is typical to error C1004.

    Please help it's very important.
    Thanks Itzik.

  2. #2
    Join Date
    Apr 2002
    Location
    United Kingdom
    Posts
    310
    try this instead

    place in stdafx.h

    #import <msxml.dll> named_guids
    using namespace MSXML;

    and the following in main or function

    Code:
    	HRESULT hr;
    	IXMLDOMDocumentPtr m_plDomDocument;
    	IXMLDOMElementPtr m_pDocRoot;
    
    	hr = m_plDomDocument.CreateInstance( CLSID_DOMDocument );
    	if (FAILED(hr))
    	{
    		 _com_error er(hr);
    		 cout << er.ErrorMessage() << endl;
    		 return 1;
    	}
    	
    	// specify xml file name
    	CString strFileName ("D:\\TEST2.xml");
    
    	// convert xml file name string to something COM can handle (BSTR)
    	_bstr_t bstrFileName;
    	bstrFileName = strFileName.AllocSysString();
    
    	// call the IXMLDOMDocumentPtr's load function to load the XML document
    	_variant_t vResult;
    	vResult = m_plDomDocument->load( bstrFileName);
    	if( (!(bool)vResult) ) 
    	{
    		cout << endl << "XML Document FAILED to load!" << endl;
    		return 1;
    	}
    
    	// now that the document is loaded, we need to initialize the root pointer
    	m_pDocRoot = m_plDomDocument->documentElement;
    
    	cout << endl << "XML Document loaded successfully!" << endl;
    
    	int nRecords = 0;
    	for( IXMLDOMNodePtr pChild=m_pDocRoot->firstChild; NULL!=pChild; pChild=pChild->nextSibling )
    	{
    		nRecords++;
    	}
    	
    	cout << endl << "Total Records: " << nRecords << endl;

  3. #3
    Join Date
    May 2002
    Posts
    12
    Why this code doesn't work? Do you have any idea?

    // Parser.h /////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////

    #include "X3DParser.h"
    #include <msxml.h>

    // This class is exported from the X3DParser.dll
    class X3DPARSER_API CX3DParser {
    public:
    CX3DParser(){};
    virtual ~CX3DParser(){};
    // TODO: add your methods here.

    protected:
    IXMLDOMDocument* m_pDoc;
    IXMLDOMNodeList* m_pNodeList;
    IXMLDOMNode* m_pNode;
    };

  4. #4
    Join Date
    Apr 2002
    Location
    Germany
    Posts
    224
    this seems something like the problem I had,

    you may want to try changing the project settings under the tag c/c++ --- category: precompiled headers

    select: not using precompiled headers.

    in my case it helped.

  5. #5
    Join Date
    Dec 2006
    Posts
    1

    Re: include msxml couse compilation error PLEASE HELP

    Check the header file like "stdafx.h". This may have an entry like #define WIN32_LEAN_AND_MEAN

    If this WIN32_LEAN_AND_MEAN is defined some of the header files which are rarely used do not get included. Removing this entry may help.

  6. #6
    Join Date
    Mar 2000
    Location
    Oxford, UK.
    Posts
    352

    Thumbs up Re: include msxml couse compilation error PLEASE HELP

    Quote Originally Posted by prasad_chawak
    Check the header file like "stdafx.h". This may have an entry like #define WIN32_LEAN_AND_MEAN

    If this WIN32_LEAN_AND_MEAN is defined some of the header files which are rarely used do not get included. Removing this entry may help.

    well done prasad. You're right.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured