>When I compile the example in:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html
/xmobjxmldomelement.asp
I get this compiler error:
'documentElement' is not a member of IXMLDOMDocument
>
I built a MFC dialog application(VC6.0) with the above sample code, it
works fine on my side, so maybe you can try to use the following instead:
#import "msxml.dll"
using namespace MSXML; //please change the MSXML2 to MSXML in others code.
>The MSXML 4.0 SDK helps shows:
HRESULT get_documentElement(IXMLDOMElement** DOMElement);
The above signature is completely different from the one in the example.
What is the correct API Signature?
This applies to other APIs like: nodeType, firstChild, etc.
Could you please explain to me why they are different?
Is it because the example uses old APIs? How old?
The new APIs in 4.0 uses get_, put_ at the beginning of the APIs?
>
There is no inconsistence here, the IXMLDOMElementPtr is just a COM smart
pointer wrapped the bare IXMLDOMElement pointer.
Additionally, the following is an sample program about using the XML DOM
from Visual C++ MFC application:
http://www.codeguru.com/Cpp/misc/misc/article.php/c3707/
Wish it helps!
Best regards,
Gary Chang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thanks for your reply!
>If I want to use MSXML 4.0, I must change the APIs from the examples to
work with this version.
>Is this correct?
You don't need to change the API's signature from the examples with
defferent MSXML versions, I can import the
"msxml4.dll" or "msxml3.dll" with the namespace MSXML2 well in my MFC
application.
If you still have that compiler error, would you please upload a small
self-contained project(zipped) to the group if it is not inconvenience?
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> Thread-Topic: Discrepancy in MSXML APIs
> thread-index: AcRE0pDPS4KolfZ5RCeAFs8YIQadlw==
> X-WN-Post: microsoft.public.xml
> From: "=?Utf-8?B?QURYIERldg==?=" <d...@newsgroups.nospam>
> References: <A67F8DC9-ACDB-40B3...@microsoft.com>
<QcGQ0$IREHA...@cpmsftngxa10.phx.gbl>
<D7489098-5473-43F7...@microsoft.com>
> Subject: RE: Discrepancy in MSXML APIs
> Date: Fri, 28 May 2004 09:41:03 -0700
> Lines: 13
> Message-ID: <71499170-3B25-4C57...@microsoft.com>
> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="Utf-8"
> Content-Transfer-Encoding: 7bit
> X-Newsreader: Microsoft CDO for Windows 2000
> Content-Class: urn:content-classes:message
> Importance: normal
> Priority: normal
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> Newsgroups: microsoft.public.xml
> Path: cpmsftngxa10.phx.gbl
> Xref: cpmsftngxa10.phx.gbl microsoft.public.xml:76517
> NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
> X-Tomcat-NG: microsoft.public.xml
>
> #import "msxml.dll" loads C:\Windows\System32\MSXML.dll
and
#import "msxml4.dll" loads C:\Windows\System32\MSXML4.dll
Is this correct?
MSXML.dll must be a very old version. Probably version 1. Right?
If I want to use MSXML 4.0, I must change the APIs from the examples to
work with this version.
Is this correct?
ADX Dev
>
I downloaded the example from:
http://www.codeguru.com/Cpp/misc/misc/article.php/c3707/
I compiled it, I got this error:
--------------------Configuration: XMLDOMFromVC - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
XMLDOMFromVCDlg.cpp
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(230) : error C2872: 'NODE_TEXT' : ambiguous symbol
Generating Code...
Skipping... (no relevant changes detected)
XMLDOMFromVC.cpp
Error executing cl.exe.
XMLDOMFromVC.exe - 1 error(s), 0 warning(s)
If I changed the line where the error is to:
if (MSXML::NODE_TEXT == pChild->nodeType)
I was able to compile it without any error.
Now...
If I changed StdAfx.h to:
#import <msxml4.dll> raw_interfaces_only //named_guids
using namespace MSXML2;
I got these compiler errors:
--------------------Configuration: XMLDOMFromVC - Win32 Debug--------------------
Compiling...
StdAfx.cpp
Compiling...
XMLDOMFromVCDlg.cpp
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(123) : error C2653: 'MSXML' : is not a class or namespace name
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(140) : error C2660: 'load' : function does not take 1 parameters
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(144) : error C2039: 'documentElement' : is not a member of 'IXMLDOMDocument'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(496) : see declaration of 'IXMLDOMDocument'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(147) : error C2039: 'xml' : is not a member of 'IXMLDOMDocument'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(496) : see declaration of 'IXMLDOMDocument'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(218) : error C2039: 'firstChild' : is not a member of 'IXMLDOMNode'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(332) : see declaration of 'IXMLDOMNode'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(220) : error C2039: 'nextSibling' : is not a member of 'IXMLDOMNode'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(332) : see declaration of 'IXMLDOMNode'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(230) : error C2872: 'NODE_TEXT' : ambiguous symbol
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(230) : error C2039: 'nodeType' : is not a member of 'IXMLDOMNode'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(332) : see declaration of 'IXMLDOMNode'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(232) : error C2039: 'text' : is not a member of 'IXMLDOMNode'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(332) : see declaration of 'IXMLDOMNode'
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(236) : error C2039: 'nodeName' : is not a member of 'IXMLDOMNode'
d:\client 4.0\msdn samples\downloads\samples\xml\codeguru dom intro\xmldomfromvc\debug\msxml4.tlh(332) : see declaration of 'IXMLDOMNode'
Generating Code...
Skipping... (no relevant changes detected)
XMLDOMFromVC.cpp
Error executing cl.exe.
XMLDOMFromVC.exe - 10 error(s), 0 warning(s)
The above errors are what I'm talking about.
According to the MSDN website, you have to import msxml4 if you want to use version 4.
Hope to hear from you soon.
I need a solution so that I can complete this part of the project.
Thanks,
ADX Dev
> FYI, I have the following msxml DLLs in my C:\WINDOWS\SYSTEM32 directory:
MSXML2.DLL
MSXML2R.DLL
MSXML3.DLL
MSXML3A.DLL
MSXML3R.DLL
MSXML4.DLL
MSXML4R.DLL
MSXML.DLL
MSXMLR.DLL
>
It's OK!
Thanks for your response!
The following #import directive is correct and enough for using
MSXML2(Don't forget to change the corresponding namespace to MSXML2::... in
the source file):
#import <msxml4.dll> named_guids
using namespace MSXML2;
>Now...
>If I changed StdAfx.h to:
>#import <msxml4.dll> raw_interfaces_only //named_guids
>using namespace MSXML2;
Why do you change the #import directive?
Do you have any particular concern on that?
If you use the "raw_interfaces_only" directive, you cannot use the wrapped
XMLDOM helper class in the sample code:
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM
Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(140) : error C2660: 'load' :
function does not take 1 parameters
If you ignore the "named_guids" directive, you will get the following error:
D:\Client 4.0\MSDN Samples\downloads\samples\XML\CodeGuru DOM
Intro\XMLDOMFromVC\XMLDOMFromVCDlg.cpp(123) : error C2039:
'CLSID_DOMDocument' : is not a member of 'MSXML2'
You can reference to the following MSDN doc's link:
The #import Directive
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html
/_predir_The_.23.import_Directive.asp
OK.
I will use:
#import <msxml4.dll> named_guids
using namespace MSXML2;
I need to understand the following:
Who releases the memory allocated by for example:
IXMLDOMDocumentPtr m_plDomDocument;
IXMLDOMElementPtr m_pDocRoot;
declared in XMLDOMFromVCDlg.h
From other examples that I read, the developer must explicitly Release memory allocated. Is this true?
See: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/xmobjxmldomselection.asp
ADX Dev
>Who releases the memory allocated by for example:
IXMLDOMDocumentPtr m_plDomDocument;
IXMLDOMElementPtr m_pDocRoot;
declared in XMLDOMFromVCDlg.h
>
The IXMLDOMDocumentPtr and IXMLDOMElementPtr are the smart pointers which
wrapped the corresponding XMLDOM interface, they will release themselves
automatically(while out of their scope), please refer to the following docs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html
/DOM_HDI_cpp_getready_smart.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncomg/html
/msdn_smart.asp
#import <msxml4.dll>
using namespace MSXML2;
in my project I get this error:
debug\msxml4.tli(49) : error C2872: 'DOMNodeType' : ambiguous symbol
I'm not able to get rid of it.
Do you have any hints?
I can compile the sample from CodeGuru without any problem.
I'm using set same settings as in my project in VC++.
ADX Dev
debug\msxml4.tli(49) : error C2872: 'DOMNodeType' : ambiguous symbol
My code calls the constants from DOMNodeType like NODE_TEXT as follows:
IXMLDOMNodePtr spChildNode = spElementIn->firstChild;
memset(cElementText,0,iBufferLength);
// Check, and keep looking until we find it
while ( (spChildNode != NULL) &&
(spChildNode->nodeType != MSXML2::NODE_TEXT) )
{
spChildNode = spChildNode->nextSibling;
}
In Tools --> Opitons --> Directories Tab,
The order of my Includes files are as follows:
C:\PROGRAM FILES\MICROSOFT\INTERNET EXPLORER 6SP1 HEADER AND LIBRARY FILES\INCLUDE
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
This is the same settings as when I compile the sample from CodeGuru without any problem.
What else is wrong?
I looked into http://support.microsoft.com/default.aspx?scid=kb;en-us;269194
and it did not help me much.
Hope to hear from you soon.
Thanks,
ADX Dev
>#import <msxml4.dll>
using namespace MSXML2;
in my project I get this error:
debug\msxml4.tli(49) : error C2872: 'DOMNodeType' : ambiguous symbol
I'm not able to get rid of it.
Do you have any hints?
>
I cannot repro this error on my side, why do you ignore the "named_guids"
directive, do you have any particular concern?
> ...
Is this correct
>
Yes, I think so.
>Can I use both of the above import statements in different files on my
project?
Or the files must be different projects?
>
You can have a test to use both of the above import statements in different
source files compile unit respectively, but we don't recommend it.
Which one?
Would you please upload your self-contained project(zipped) to me(as an
attachment of reply message)?
Unfortunately I don't have a separate seft-containted zipped project to give you. I need to create it and try it out. Also I need to see if I get the same error. The compiler error I'm getting is combined with my software project which I cannot send to you. It's proprietary code. Worst come to worst, I'll use raw interface. I know that works because I have started to do so. I have to worry about clearing the memory used. We have existing program files which already the raw interface.
ADX Dev
Thanks for your quickly response!
..since the example we discussed early is a non "raw interface" program,
it appears the problem is about using the raw interface of the XMLDOM
object, am I right?
If so, the usage of the XMLDOM object under raw interface scenario would be
same as that of the MSXML 4.0 SDK, and if you could make a small sample
project(not your real project, just a sample) which can repro the build
error to the group(zipped), I think we can perform more research on this
issue.
I replied to your email v-ga...@online.microsoft.com with this information:
Attached you can find the project with the samples file as it from the website: http://www.awprofessional.com/titles/0321154940
This is the compiler error I’m getting from Visual Studio C++ 6.0. I have MSXML 4.0 SP1 on my XP.
--------------------Configuration: Import - Win32 Debug--------------------
Compiling...
TargetConverter.cpp
d:\test\import\debug\msxml4.tli(49) : error C2872: 'DOMNodeType' : ambiguous symbol
Error executing cl.exe.
Import.exe - 1 error(s), 0 warning(s)
Hope to hear from you soon.
ADX Dev
I have received your sample project and built it on my machine, it complied
well after I removed the SourceConverter OLD.cpp file(except bundles of
trivial warnings).
I have installed the MSXML SP2 on my machine, the following is some
corresponding code snippet from the msxml4.tli:
// Created by Microsoft (R) C/C++ Compiler Version 12.00.8964.0 (e1a07be7).
//
// d:\test\april\adximport\Import\debug\msxml4.tli
//
// Wrapper implementations for Win32 type library msxml4.dll
// compiler-generated file created 06/15/04 at 14:44:43 - DO NOT EDIT!
..
#pragma implementation_key(5)
inline DOMNodeType MSXML2::IXMLDOMNode::GetnodeType ( ) {
DOMNodeType _result;
HRESULT _hr = get_nodeType(&_result);
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _result;
}
..
Is there anything different from yours?
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
--------------------
""Gary Chang"" wrote:
> Hi Carlos,
>
> I have received your sample project and built it on my machine, it complied
> well after I removed the SourceConverter OLD.cpp file(except bundles of
> trivial warnings).
>
> I have installed the MSXML SP2 on my machine, the following is some
> corresponding code snippet from the msxml4.tli:
> // Created by Microsoft (R) C/C++ Compiler Version 12.00.8964.0 (e1a07be7).
> //
> // d:\test\april\adximport\Import\debug\msxml4.tli
> //
> // Wrapper implementations for Win32 type library msxml4.dll
> // compiler-generated file created 06/15/04 at 14:44:43 - DO NOT EDIT!
> ...
> #pragma implementation_key(5)
> inline DOMNodeType MSXML2::IXMLDOMNode::GetnodeType ( ) {
> DOMNodeType _result;
> HRESULT _hr = get_nodeType(&_result);
> if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
> return _result;
> }
> ...
I got your msxml4.tli and it is the same as mine as you mentioned, but I
don't get such error on my side, I found one different point is:
The order of your Includes files are as follows:
C:\PROGRAM FILES\MICROSOFT\INTERNET EXPLORER 6SP1 HEADER AND LIBRARY
FILES\INCLUDE
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
(you figured in the early post)
and mine is like:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\PROGRAM FILES\MICROSOFT SDK\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
It appears the source code doesn't need the latest header file to compile.
By the way, I think the KB article 269194 is related to your problem.
Thanks!
Best regards,
Gary Chang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
I agree with you if I set the Include files like yours, I can compile the sample code without any error.
I'm glad you have found the problem. The newest file: C:\PROGRAM FILES\MICROSOFT\INTERNET EXPLORER 6SP1 HEADER AND LIBRARY conflicts with the other include files.
I have completed converting the sample codes to raw interface. The sample code compiles now. I must make sure I release the memory after it is done. This is my workaround.
Since my application uses MFC and the latest ATL WebBrowser Control which works with Internet Explorer 6, I'd like to leave the other of the include files the way it is. In order to use the latest features of the ATL, the IE6 headers must be the 1st one on the list. The rest of my application is happy with it.
Thanks for your help.
ADX Dev