on 02-13-2008 5:08 PM
Hi All,
I want to delete elements of a node.
Can someone tell me how to do it. Please provide some sample code.
Regards
Nikhil Bansal
No Problem : here it is:
// loop backwards to avoid index troubles
for (int ld_i = ld_n - 1; ld_i >= 0; --ld_i) {
wdContext.nodeInputItemCond_Val().removeElement(wdContext.nodeInputItemCond_Val().getElementAt(ld_i));
}//endfor
Edited by: Armin Reichert on Feb 13, 2008 7:48 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The node reorganizes it's elements when you delete an element: If you delete the element at index 0, a new element will be sitting at index 0. Thus, if you'd loop forward, you'd only delete half of the elements (skipping 1 with every loop) and probably even getting an exception when you have processed half of the elements, since you'll then be requesting an element index that does not exist anymore.
If you need to delete all elements of a node, the invalidate() method is the way to go though.
Hi,
An easier way would be to just invalidate the node. If you have a node called Test under the root, then clear all element list by :
wdContext.nodeTest().invalidate();
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.