Using XML in the .NET Framework " Chapter 4 121 the context node freely without invalidating it. However, if the developer attempts to move out of this deleted subtree, the node that originally contained it in the XML document will effectively recapture it, maintaining the position in the document tree as if the <category /> node had never been deleted and a call to move to the next sibling of that node was received. Figure 4.7 XML Document Fragment & <category name="Friends"> <entry name="Dave Thomas" phoneNumber="555-1212" /> <entry name="Ronald McDonald" phoneNumber="555-1213" /> </category> & NodeFilter The NodeFilter interface is used to further define a filter on the nodes returned by the logical view of either the NodeIterator or TreeWalker. It does this by its single method, acceptNode().This method allows a NodeIterator or TreeWalker to ask the filter whether the current node should be present in the logical view. If a NodeFilter rejects the node in question, the process of selecting a node is repeated until a node is accepted by the filter. If no node is found, a null value is returned. Examine the mock C# code in Figure 4.8. Figure 4.8 NodeFilter Mock C# Code public Node nextNode() { while(NodeFilter.acceptNode(this.nodes[this.position]) == FILTER_SKIP && this.position < this.length) { this.position++; } if(this.position >= this.length) return null; else return this.nodes[this.position]; } www.syngress.com 155_xml_net_pd_C04.qk 3/6/02 1:57 PM Page 121