[xml] xmlTextReaderExpand expanding until the end of a tree ?

Hi all:
I have a question regarding the behaviour of xmlTextReaderExpand ( ), shouldn't the function merely expands the subtree from the current node instead of the entire tree from the current node ?
for example, if my xml file looks like this,  and my reader is on the first group (name="gg).
<group name="gg">
 <group name="aa">
        <hh name="bb">
if I use function xmlTextReaderExpand, shouldn't I get a xmlNode whose next node is NULL ? or at least the expanded tree can't extend further into group (name="aa").
Cause I have this small function that traverses recursively the subtree under the xmlNode returned by xmlTextReaderExpand( ) function.
void traverseNode(xmlNodePtr node, int level)
   xmlNodePtr tmp_node;
   tmp_node = node;
   while (tmp_node != NULL)
      if (tmp_node->type == 1)
         printf("Level= %d <%s ", level, tmp_node->name);
         printf(" >\n");
      if (tmp_node->children != NULL)
         traverseNode(tmp_node->children, level+1);
      tmp_node = tmp_node->next;
and it always travels to the end of the tree instead of quitting at the right level.
I had a look in xmlTextReaderExpand( ) and found this piece of code
 if (reader->ctxt->nodeNr < reader->depth)
looks like this is for the purpose of quitting at the right level (please correct me if I'm wrong), however this doesn't seems to work. Thanks for your time reading this and I will greatly appreciate if anyone can share their experience on this.

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