469,362 Members | 2,611 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

IXMLDOMDocument::loadXML fails on what seems to be a perfectly fine xml

Hi,

I am trying to parse an XML file using DOM in VC++.

I need an element which is inside other elements.

So I am loading the file.

Calling GetElementsByTagName to get the first level elements.

Iterating through them, get to the one I need and here I am actually in
need of another GetElementsByTagName.

Of course there is no such func in IXMLDOMNode.

Therefore I am creating another IXMLDOMDocument and trying to load into
it that inner xml part of my desired node, by using IXMLDOMNode::xml
property.

I am using loadXML, of course.

And it fails, it returns -1.

While when I substitute that pNode->xml for the same xml piece I copy
and paste from my file it works fine.

I have displayed the pNode->xml and it looks fine. Well structured and
etc.

Please help!

Any ideas ? Leads ?

Thank you!


Nov 12 '05 #1
3 6251
I have tried to get the error using IXMLDOMParseError.
The reason property is empty.
The error code property is 0.

"Alexandra" <al***********@gmail.com> wrote in message
news:e5*************@tk2msftngp13.phx.gbl:
Hi,

I am trying to parse an XML file using DOM in VC++.

I need an element which is inside other elements.

So I am loading the file.

Calling GetElementsByTagName to get the first level elements.

Iterating through them, get to the one I need and here I am actually in
need of another GetElementsByTagName.

Of course there is no such func in IXMLDOMNode.

Therefore I am creating another IXMLDOMDocument and trying to load into
it that inner xml part of my desired node, by using IXMLDOMNode::xml
property.

I am using loadXML, of course.

And it fails, it returns -1.

While when I substitute that pNode->xml for the same xml piece I copy
and paste from my file it works fine.

I have displayed the pNode->xml and it looks fine. Well structured and
etc.

Please help!

Any ideas ? Leads ?

Thank you!


Nov 12 '05 #2
"Alexandra" <al***********@gmail.com> wrote in message
news:e5*************@tk2msftngp13.phx.gbl
I am trying to parse an XML file using DOM in VC++.

I need an element which is inside other elements.

So I am loading the file.

Calling GetElementsByTagName to get the first level elements.
Note that getElementsByTagName returns all matching elements under the
current node or within a current document no matter how deep, not just
immediate children. I'm not sure what you mean by "first level elements"
here.
Iterating through them, get to the one I need and here I am actually
in need of another GetElementsByTagName.

Of course there is no such func in IXMLDOMNode.


.... but there is on IXMLDOMElement. You can QueryInterface from the
former to the latter.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Nov 12 '05 #3
Hi Alexandra!
I am using loadXML, of course.

And it fails, it returns -1.


Are you sure that the passed string is UTF-16?
The "loadXML" function only works with UTF_16 strings! (see docu)
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ajay | last post: by
2 posts views Thread by Joe | last post: by
1 post views Thread by chander | last post: by
3 posts views Thread by =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.