A
Alan
It appears that the method getNextSibling() in the Node
(org.w3c.dom) interface never returns null. I cannot find what I am
doing wrong. The code below is an infinite loop, although I think I
am using the stopping criteria described for the method (returns null
if no next sibling exists).
What is wrong here? I have provided my method (after being
distilled down and still does not work) and the output I`m seeing. I
am not sure why it always shows a name for the next sibling node, when
it`s only 2-3 nodes deep.
Thanks in advance for any pointers you can give me. Alan
private static Node updateSibling(Node node)
{
Node sibling = node.getNextSibling();
// while there is another sibling
// but the one searching for has not been found
int count = 0;
while (sibling != null)
{
count++;
System.out.println(" count = " + count);
System.out.println("Sibling = " + sibling);
sibling = node.getNextSibling();
}
return node;
}
Output:
count = 1
Sibling = [w:r: null]
count = 2
Sibling = [w:r: null]
count = 3
Sibling = [w:r: null]
count = 4
Sibling = [w:r: null]
count = 5
Sibling = [w:r: null]
count = 6
Sibling = [w:r: null]
count = 7
Sibling = [w:r: null]
count = 8
Sibling = [w:r: null]
count = 9
Sibling = [w:r: null]
count = 10
Sibling = [w:r: null]
. . .
count = 22909
Sibling = [w:r: null]
.. . .
(org.w3c.dom) interface never returns null. I cannot find what I am
doing wrong. The code below is an infinite loop, although I think I
am using the stopping criteria described for the method (returns null
if no next sibling exists).
What is wrong here? I have provided my method (after being
distilled down and still does not work) and the output I`m seeing. I
am not sure why it always shows a name for the next sibling node, when
it`s only 2-3 nodes deep.
Thanks in advance for any pointers you can give me. Alan
private static Node updateSibling(Node node)
{
Node sibling = node.getNextSibling();
// while there is another sibling
// but the one searching for has not been found
int count = 0;
while (sibling != null)
{
count++;
System.out.println(" count = " + count);
System.out.println("Sibling = " + sibling);
sibling = node.getNextSibling();
}
return node;
}
Output:
count = 1
Sibling = [w:r: null]
count = 2
Sibling = [w:r: null]
count = 3
Sibling = [w:r: null]
count = 4
Sibling = [w:r: null]
count = 5
Sibling = [w:r: null]
count = 6
Sibling = [w:r: null]
count = 7
Sibling = [w:r: null]
count = 8
Sibling = [w:r: null]
count = 9
Sibling = [w:r: null]
count = 10
Sibling = [w:r: null]
. . .
count = 22909
Sibling = [w:r: null]
.. . .