tags:

views:

559

answers:

2

I have an xml string

<grandparent>
   <parent>
       <child>dave</child>
       <child>laurie</child>
       <child>gabrielle</child>
   </parent>
</grandparrent>

What I want to get is the data raw xml that's inside the parent. I'm using MSXML

iXMLElm->get_xml(&bStr);

is returning

<parent>
   <child>dave</child>
   <child>laurie</child>
   <child>gabrielle</child>
</parent>

.

iXMLElm->get_text(&bStr);

returns davelauriegabrielle

What function do I use if I want to get?

<child>dave</child>
   <child>laurie</child>
   <child>gabrielle</child>

Is anyone aware of some good documentation on these functions? Everything I've seen is a linked nightmare.

+1  A: 

Iterate over the child nodes and build the string manually.

Judge Maygarden
A: 

If you are using MSXML, this should be a case of getting the child node of the grandparent node.

So, if iXMLElm is the grandparent and it has only one child node, you can just use...

 iXMLElm->get_firstChild(&iXMLChildElm)

...and then...

 iXMLChildElm->get_xml(&bStr)

...to get the three child elements.

If there are multiple items under grandparent you could use selectSingleNode instead to use XPath for selecting the node with the inner XML you want.

The MSDN documentation is quite reasonable on the interfaces and calls available.

Jeff Yates