Discussion:
how to use MSXML2 (msxml2.h)
(too old to reply)
nick
2005-06-01 08:26:01 UTC
Permalink
I'm facing some problems using MSXML to read an validate XML documents
that are defined in a XML schema (MSXML::DOMDocument.load() blocks
if there are errors like missing closing tag in the XML document instance
even if I don't reference a schema).

Tried to use MSXML2 but as soon as I include msxml2.h
---------------------------
namespace MSXML2
{
#include <msxml2.h>
}
---------------------------

I get compiler errors:
---------------------------
:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3502) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3679) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3767) : error C2504: 'IXMLDOMDocument' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3779) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(4472) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11035) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11038) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11157) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11169) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11253) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11608) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19920) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19980) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20007) : error C2504: 'IXMLDOMNodeList' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20016) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20019) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20022) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20025) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20029) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20276) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20288) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20300) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20312) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20325) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20510) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20513) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20652) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20664) : error C2061: syntax error : identifier
'IXMLDOMDocument'
Error executing clarm.exe.

xml_configDlg.obj - 28 error(s), 0 warning(s)
---------------------------

and here is the code:
---------------------------

typedef CComPtr<MSXML::IXMLDOMDocument> IXMLDOMDocumentPtr;

int CXml_configDlg::parseXML()
{

HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if (hr == S_FALSE)
{
STLOG_WRITE(_T("COM already initialized"));
}
else if (hr != S_OK)
{
STLOG_WRITE(_T("CoInitializeEx failed"));
return -1;
}

CString sFilePath = _T("\\values.xml");
IXMLDOMDocumentPtr pXMLDoc;
COleVariant vXmlFile(sFilePath);
VARIANT_BOOL vSuccess;

hr = pXMLDoc.CoCreateInstance(__uuidof (MSXML::DOMDocument));
if (hr != S_OK)
{
STLOG_WRITE(_T("CoCreateInstance() failed"));
return -1;
}


pXMLDoc->put_validateOnParse(VARIANT_TRUE);
pXMLDoc->put_resolveExternals(VARIANT_FALSE);
pXMLDoc->put_preserveWhiteSpace(VARIANT_FALSE);

hr = pXMLDoc->load(vXmlFile,&vSuccess);
if (hr != S_OK)
{
STLOG_WRITE(_T("XML load failed"));
return -1;
}

STLOG_WRITE(_T("XML document loaded"));

return 0;
}
---------------------------

Has anyone used XML schema on PPC 2003 second edition?

Help is greatly appreciated.
/nick
John Spaith [MS]
2005-06-01 16:27:10 UTC
Permalink
Msxml2.h actually corresponds to msxml3.dll. On WinCE, we do not have a
side-by-side mode like the desktop has. If you're using CE 4.0 or above
you're using msxml3. I've never used the "namespace" keyword but I think if
you remove that everything should build again - as I said it wouldn't give
you a different version of msxml in either case.

As far as hanging on invalid XML -- this sounds a lot like a known bug in
the EVC debugger. Basically MSXML3 internally calls RaiseException() when
there's a parse error and then handles that exception in a __try/__except
bloc, but EVC gets confused when this happens. Try running without the
debugger attached to see if this is the case.

http://groups-beta.google.com/group/microsoft.public.windowsce.embedded.vc/browse_frm/thread/ea1d387dfb63f077/d351f84a2dce49a3?q=spaith+msxml+hang&rnum=1&hl=en#d351f84a2dce49a3
has more details - click on the "show quoted text" under my post since I
copied & pasted an email thread that google thought was an old newsgroup
post and hence hid.
--
John Spaith
Software Design Engineer, Windows CE
Microsoft Corporation

Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights
reserved.
Post by nick
I'm facing some problems using MSXML to read an validate XML documents
that are defined in a XML schema (MSXML::DOMDocument.load() blocks
if there are errors like missing closing tag in the XML document instance
even if I don't reference a schema).
Tried to use MSXML2 but as soon as I include msxml2.h
---------------------------
namespace MSXML2
{
#include <msxml2.h>
}
---------------------------
---------------------------
:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3502) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3679) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3767) : error C2504: 'IXMLDOMDocument' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3779) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(4472) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11035) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11038) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11157) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11169) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11253) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11608) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19920) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19980) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20007) : error C2504: 'IXMLDOMNodeList' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20016) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20019) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20022) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20025) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20029) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20276) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20288) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20300) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20312) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20325) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20510) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20513) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20652) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20664) : error C2061: syntax error : identifier
'IXMLDOMDocument'
Error executing clarm.exe.
xml_configDlg.obj - 28 error(s), 0 warning(s)
---------------------------
---------------------------
typedef CComPtr<MSXML::IXMLDOMDocument> IXMLDOMDocumentPtr;
int CXml_configDlg::parseXML()
{
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (hr == S_FALSE)
{
STLOG_WRITE(_T("COM already initialized"));
}
else if (hr != S_OK)
{
STLOG_WRITE(_T("CoInitializeEx failed"));
return -1;
}
CString sFilePath = _T("\\values.xml");
IXMLDOMDocumentPtr pXMLDoc;
COleVariant vXmlFile(sFilePath);
VARIANT_BOOL vSuccess;
hr = pXMLDoc.CoCreateInstance(__uuidof (MSXML::DOMDocument));
if (hr != S_OK)
{
STLOG_WRITE(_T("CoCreateInstance() failed"));
return -1;
}
pXMLDoc->put_validateOnParse(VARIANT_TRUE);
pXMLDoc->put_resolveExternals(VARIANT_FALSE);
pXMLDoc->put_preserveWhiteSpace(VARIANT_FALSE);
hr = pXMLDoc->load(vXmlFile,&vSuccess);
if (hr != S_OK)
{
STLOG_WRITE(_T("XML load failed"));
return -1;
}
STLOG_WRITE(_T("XML document loaded"));
return 0;
}
---------------------------
Has anyone used XML schema on PPC 2003 second edition?
Help is greatly appreciated.
/nick
John Spaith [MS]
2005-06-01 16:37:32 UTC
Permalink
And no matter what the issue is let me apologize for the time you've had to
waste on this so far.
--
John Spaith
Software Design Engineer, Windows CE
Microsoft Corporation

Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights
reserved.
Post by John Spaith [MS]
Msxml2.h actually corresponds to msxml3.dll. On WinCE, we do not have a
side-by-side mode like the desktop has. If you're using CE 4.0 or above
you're using msxml3. I've never used the "namespace" keyword but I think
if you remove that everything should build again - as I said it wouldn't
give you a different version of msxml in either case.
As far as hanging on invalid XML -- this sounds a lot like a known bug in
the EVC debugger. Basically MSXML3 internally calls RaiseException() when
there's a parse error and then handles that exception in a __try/__except
bloc, but EVC gets confused when this happens. Try running without the
debugger attached to see if this is the case.
http://groups-beta.google.com/group/microsoft.public.windowsce.embedded.vc/browse_frm/thread/ea1d387dfb63f077/d351f84a2dce49a3?q=spaith+msxml+hang&rnum=1&hl=en#d351f84a2dce49a3
has more details - click on the "show quoted text" under my post since I
copied & pasted an email thread that google thought was an old newsgroup
post and hence hid.
--
John Spaith
Software Design Engineer, Windows CE
Microsoft Corporation
Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/.
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights
reserved.
Post by nick
I'm facing some problems using MSXML to read an validate XML documents
that are defined in a XML schema (MSXML::DOMDocument.load() blocks
if there are errors like missing closing tag in the XML document instance
even if I don't reference a schema).
Tried to use MSXML2 but as soon as I include msxml2.h
---------------------------
namespace MSXML2
{
#include <msxml2.h>
}
---------------------------
---------------------------
:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3502) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3679) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3767) : error C2504: 'IXMLDOMDocument' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(3779) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(4472) : error C2061: syntax error : identifier
'IXMLDOMParseError'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11035) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11038) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11157) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11169) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11253) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(11608) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19920) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(19980) : error C2061: syntax error : identifier
'XML_ERROR'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20007) : error C2504: 'IXMLDOMNodeList' : base
class undefined
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20016) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20019) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20022) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20025) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20029) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20276) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20288) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20300) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20312) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20325) : error C2061: syntax error : identifier
'IXMLDOMNode'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20510) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20513) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20652) : error C2061: syntax error : identifier
'IXMLDOMDocument'
c:\program files\windows ce tools\wce420\pocket pc
2003\include\armv4\msxml2.h(20664) : error C2061: syntax error : identifier
'IXMLDOMDocument'
Error executing clarm.exe.
xml_configDlg.obj - 28 error(s), 0 warning(s)
---------------------------
---------------------------
typedef CComPtr<MSXML::IXMLDOMDocument> IXMLDOMDocumentPtr;
int CXml_configDlg::parseXML()
{
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (hr == S_FALSE)
{
STLOG_WRITE(_T("COM already initialized"));
}
else if (hr != S_OK)
{
STLOG_WRITE(_T("CoInitializeEx failed"));
return -1;
}
CString sFilePath = _T("\\values.xml");
IXMLDOMDocumentPtr pXMLDoc;
COleVariant vXmlFile(sFilePath);
VARIANT_BOOL vSuccess;
hr = pXMLDoc.CoCreateInstance(__uuidof (MSXML::DOMDocument));
if (hr != S_OK)
{
STLOG_WRITE(_T("CoCreateInstance() failed"));
return -1;
}
pXMLDoc->put_validateOnParse(VARIANT_TRUE);
pXMLDoc->put_resolveExternals(VARIANT_FALSE);
pXMLDoc->put_preserveWhiteSpace(VARIANT_FALSE);
hr = pXMLDoc->load(vXmlFile,&vSuccess);
if (hr != S_OK)
{
STLOG_WRITE(_T("XML load failed"));
return -1;
}
STLOG_WRITE(_T("XML document loaded"));
return 0;
}
---------------------------
Has anyone used XML schema on PPC 2003 second edition?
Help is greatly appreciated.
/nick
nick
2005-06-02 02:10:05 UTC
Permalink
OK, this did the trick. If I don't attach the debugger the load() method
does not block anymore.

However, the XML document is also loaded without parsing errors if it
does not correspond to the XML schema referenced. Is it true that
MSXML3 does not support XML schema. Do I need MSXML4? Is there
a way to make it work on CE 4.2 (WIndows Mobile 2003 second edition
Version 4.21.1088)?


many thanks
/nick
John Spaith [MS]
2005-06-02 21:55:20 UTC
Permalink
It's a little confusing, but even though PocketPC 2003 was built on top of
WinCE 4.2 they didn't use the CE 4.2 MSXML. PPC 2003 ships MSXML2 SP1,
WinCE shipped MSXML3. There's no option on any CE platform to go to MSXML4.

XML Schemas (XSD) were added in MSXML4 so there's no option on WinCE to have
MSXML automatically do this for you. Sorry. The only solution here is to
have your app do the validation itself.
--
John Spaith
Software Design Engineer, Windows CE
Microsoft Corporation

Check out the new CE Networking Team Blog at http://blogs.msdn.com/cenet/.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2003 Microsoft Corporation. All rights
reserved.
Post by nick
OK, this did the trick. If I don't attach the debugger the load() method
does not block anymore.
However, the XML document is also loaded without parsing errors if it
does not correspond to the XML schema referenced. Is it true that
MSXML3 does not support XML schema. Do I need MSXML4? Is there
a way to make it work on CE 4.2 (WIndows Mobile 2003 second edition
Version 4.21.1088)?
many thanks
/nick
Loading...