[xml] counting nodes before or after doc is saved?



If I parse an xml doc from a file, I am able to (using xpath) count how many of any particular node (corresponding to the xpath) are in the tree, using xpathObj->nodesetval->nodeNr.

But if I am in the middle of creating a tree from scratch, and try to count already-created nodes using the same method (using a new xpathCtx and xpathObj for each count, so as not to be getting stale values), I get nodeNr = 0.

Am I missing some step, or looking at this incorrectly? Does the tree somehow have to be "flushed" and "reread" to properly "register" nodes (my poor guesses at terminology)? Surely I don't have to write the tree out as a file and reparse it...

I would have to create simpler sample code that what I have right now to try to demonstrate, but I thought I'd post the question alone first in case I'm missing the obvious.


Stefan Jeglinski




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