EDN Admin
Well-known member
Hi,<br/>
I use this xml (the password to open it below is 1324) to run the below codes in C++ 2008 ver.
<br/>
http://dl.dropbox.com/u/40211031/List.rar<br/>
<br/>
#include "stdafx.h"<br/>
#import "MSXML6.dll" rename_namespace(_T("MSXML"))<br/>
#include <msxml2.h><br/>
#include <list><br/>
#include <string><br/>
#include <iostream><br/>
using namespace std;<br/>
void XMLDOMParsingNodes(char*);<br/>
int _tmain(int argc, _TCHAR* argv[])<br/>
{<br/>
try<br/>
{<br/>
XMLDOMParsingNodes("C:\List.xml");<br/>
}<br/>
catch(_com_error &e)<br/>
{<br/>
_bstr_t source(e.Source());<br/>
_bstr_t description(e.Description());<br/>
wcout << L"Error: " << e.Error() << endl;<br/>
wcout << L"ErrorMessage: " << e.ErrorMessage() << endl;<br/>
wcout << L"Source" << (!source ? L"" : static_cast<const wchar_t*>(source)) << endl;<br/>
wcout << L"Description: " <<(!description ? L"" : static_cast<const wchar_t*>(description)) << endl;<br/>
} <br/>
return 0;<br/>
}<br/>
void XMLDOMParsingNodes(char *szFileName)<br/>
{<br/>
try<br/>
{<br/>
MSXML::IXMLDOMDocument2Ptr docPtr;<br/>
MSXML::IXMLDOMNodeListPtr NodeListPtr;<br/>
MSXML::IXMLDOMNodePtr DOMNodePtr;<br/>
MSXML::IXMLDOMNode *pIDOMNode = NULL;<br/>
MSXML::IXMLDOMNode *pIParentNode = NULL;<br/>
MSXML::IXMLDOMNode *pIAttrNode = NULL;<br/>
MSXML::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr;<br/>
MSXML::IXMLDOMNodeList *childList=NULL;<br/>
<br/>
BSTR strFindText = L" ";<br/>
<br/>
BSTR bstrAttrName, bstrAttrText;<br/>
<br/>
BSTR bstrXPath = L"<br/>
HRESULT hResult;<br/>
int i = 0;<br/>
int n = 0;<br/>
<br/>
CoInitialize(NULL);<br/>
<br/>
docPtr.CreateInstance(__uuidof(DOMDocument30));<br/>
<br/>
_variant_t varXml(szFileName);<br/>
_variant_t varResult((bool)TRUE);<br/>
varResult = docPtr->load(varXml);<br/>
if ((bool)varResult == FALSE)<br/>
{<br/>
<br/>
MessageBox(NULL, _T("Error: failed to load XML file. Check the file name."), _T(".."), MB_OK);<br/>
return;<br/>
}<br/>
...<br/>
I dont know why this last error message above is fired due to the file. <br/>
<
Many Thanks & Best Regards, Hua Min
<br/>
View the full article
I use this xml (the password to open it below is 1324) to run the below codes in C++ 2008 ver.
<br/>
http://dl.dropbox.com/u/40211031/List.rar<br/>
<br/>
#include "stdafx.h"<br/>
#import "MSXML6.dll" rename_namespace(_T("MSXML"))<br/>
#include <msxml2.h><br/>
#include <list><br/>
#include <string><br/>
#include <iostream><br/>
using namespace std;<br/>
void XMLDOMParsingNodes(char*);<br/>
int _tmain(int argc, _TCHAR* argv[])<br/>
{<br/>
try<br/>
{<br/>
XMLDOMParsingNodes("C:\List.xml");<br/>
}<br/>
catch(_com_error &e)<br/>
{<br/>
_bstr_t source(e.Source());<br/>
_bstr_t description(e.Description());<br/>
wcout << L"Error: " << e.Error() << endl;<br/>
wcout << L"ErrorMessage: " << e.ErrorMessage() << endl;<br/>
wcout << L"Source" << (!source ? L"" : static_cast<const wchar_t*>(source)) << endl;<br/>
wcout << L"Description: " <<(!description ? L"" : static_cast<const wchar_t*>(description)) << endl;<br/>
} <br/>
return 0;<br/>
}<br/>
void XMLDOMParsingNodes(char *szFileName)<br/>
{<br/>
try<br/>
{<br/>
MSXML::IXMLDOMDocument2Ptr docPtr;<br/>
MSXML::IXMLDOMNodeListPtr NodeListPtr;<br/>
MSXML::IXMLDOMNodePtr DOMNodePtr;<br/>
MSXML::IXMLDOMNode *pIDOMNode = NULL;<br/>
MSXML::IXMLDOMNode *pIParentNode = NULL;<br/>
MSXML::IXMLDOMNode *pIAttrNode = NULL;<br/>
MSXML::IXMLDOMNamedNodeMapPtr DOMNamedNodeMapPtr;<br/>
MSXML::IXMLDOMNodeList *childList=NULL;<br/>
<br/>
BSTR strFindText = L" ";<br/>
<br/>
BSTR bstrAttrName, bstrAttrText;<br/>
<br/>
BSTR bstrXPath = L"<br/>
HRESULT hResult;<br/>
int i = 0;<br/>
int n = 0;<br/>
<br/>
CoInitialize(NULL);<br/>
<br/>
docPtr.CreateInstance(__uuidof(DOMDocument30));<br/>
<br/>
_variant_t varXml(szFileName);<br/>
_variant_t varResult((bool)TRUE);<br/>
varResult = docPtr->load(varXml);<br/>
if ((bool)varResult == FALSE)<br/>
{<br/>
<br/>
MessageBox(NULL, _T("Error: failed to load XML file. Check the file name."), _T(".."), MB_OK);<br/>
return;<br/>
}<br/>
...<br/>
I dont know why this last error message above is fired due to the file. <br/>
<
Many Thanks & Best Regards, Hua Min
<br/>
View the full article