[xml] Problem reading inner text when parsing through xpatha



I have an xml doc like this

 

<a>

 <b>

   <!--asda-->

      <c c1=”a”> Innext text </c>

      <d c1=”a”> Innext text </d>

</b>

<b>

   <!--asda-->

      <c c1=”a”> Innext text </c>

      <d c1=”a”> Innext text </d>

</b>

</a>

 

And I am trying to get the Inner text of b nodes (technically I need nothing as output as b is an element node)

 

I am using something like this to parse

             xmlXPathObjectPtr result = GetXpathNodes(xpath); //Assuming this gets me the xpathObjectPtr

                xmlNodeSetPtr nodeset;

                if (result)

                {

                                nodeset = result->nodesetval;

                               

                                for (int i=0; i < nodeset->nodeNr; i++)

                                {

                                                xmlChar *keyword= xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1);

                                               

                                                if(keyword!=NULL)

                                                {
                                                                cout<<keyword;              

                                                }

                                                xmlFree(keyword);

                                               

 

                                }

                                xmlXPathFreeObject (result);

                }

     

Is this correct?    Its appending all new lines and spaces but no characters.

 

 

Thanks,

Ram

 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]