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

  • Thread starter Thread starter Alexandra
  • Start date Start date
A

Alexandra

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!
 
I have tried to get the error using IXMLDOMParseError.
The reason property is empty.
The error code property is 0.
 
Alexandra said:
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
 
Back
Top