Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: XML exception( my MSN : lookus.cn@gmail.com)

From: ulger@(--------).---------.---
To: NULL
Date: 5/2/2006 2:29:00 PM

If your xml file is exactly like

<Book id="00322032"><Author>lookus</Author></Book>
<Bok id="003232"><Author>ookus</Author></Book>

Then it is an invalid xml file. (There must be only one root node in the xml 
file and your opening and closing element names should match).

-- 
Sih Huseyin Ulger [MSFT]
MSXML Dev


"lookus" wrote:

> I'm a newer to xml. And i wanna to use msxml to read xml file.
> here is my code
> ////// msxml_test.cpp
> ////// use MFC in a shared dll
> #include <iostream>
> #include <cmath>
> #include <string>
> #import <msxml4.dll>
> #include <msxml.h>
> using namespace std;
> 
> int main()
> {
> 
> 	cout << "BEGIN" <<endl;
> 
> 	HRESULT hr;
> 	long cnt;
> 	try
> 	{
> 
> 		hr = ::CoInitialize(NULL);
> 
> 		MSXML2::IXMLDOMDocumentPtr pDoc;
> 		MSXML2::IXMLDOMNodeListPtr pNodeList;
> 		MSXML2::IXMLDOMNodePtr pNode;
> 
> 		if(FAILED(hr))
> 			throw "failed to com init";
> 
> 		hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40));
> 		if(FAILED(hr))
> 			throw "failed to create DOM DOC";
> 
> 		pDoc->load("d:\\test.xml");
> 
> 		pDoc->get_childNodes(&pNodeList);
> 
> 		//////  From here
> 		pNodeList->get_length(&cnt);
> 
> 		cout << "LENGTH  " << cnt << endl;
> 
> 		for(cnt = 0 ; (pNode = pNodeList->nextNode()) ; ++cnt);
> 
> 		cout << "Node count " << cnt <<endl;
> 
> 		//////  to here
> 
> 	}
> 	catch (string str)
> 	{
> 		cout << "Exception : " << str << endl;
> 	}
> 	catch (...)
> 	{
> 		cout << "Exception Unkonwn\n";
> 	}
> 
> 	::CoUninitialize();
> 
> 	cout << "END" <<endl;
> 
> 	return 0;
> }
> ///////////////////////
> 
> ******************************   1
> when the test.xml is
> 
> <Book id="00322032"><Author>lookus</Author></Book>
> 
> it works well, and prints :
> BEGIN
> LENGTH  1
> Node count 1
> END
> 
> ******************************   2
> however when test.xml is
> 
> <Book id="00322032"><Author>lookus</Author></Book>
> <Bok id="003232"><Author>ookus</Author></Book>
> 
> it prints :
> BEGIN
> LENGTH  0
> Node count 0
> END
> 
> but it's excepted to print
> BEGIN
> LENGTH  2
> Node count 2
> END
> 
> ###################################################### More
> in msdn there is
> 
> IXMLDOMNodeList::nextNode
> The nextNode method retrieves the next node in the IXMLDOMNodeList
> collection.
> HRESULT nextNode(
>   IXMLDOMNode** ppNextItem
> );
> 
> but when i wrote i got "error C2660: 'nextNode' : function does not
> take 1 parameters"
> 
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> My MSN and email is lookus.cn@g....
> I will appreciate your help.
> 
> 


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent