472,131 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,131 software developers and data experts.

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 6483
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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.