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).
<system>
<group name="gg"> </group> <group
name="aa">
<hh name="bb"> </hh> </group> </system> 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.
8<------------------------------------------------------------
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; } } >8-----------------------------------------------------------
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)
return(1); 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.
C_Liao
|