The text of an element is contained in text
nodes that are children of the element node. It's always a little awkward
to get it out.
Elements can have any number of children,
so you may want to generalize your code a bit. Even if there are no
nested elements, comments and entity reference nodes can still appear. You
probably want to ignore comments altogether and recursively look for more text
nodes among the children of any entity ref nodes.
It may be sligthly simpler to use
Node.getFirstChild() and getNextSibling() methods for navigation, rather than
the node list.
-- Andy
|
- Newby question: Get Text of a Node Nathan Troxler
- RE: Newby question: Get Text of a Node Andy Heninger
- RE: Newby question: Get Text of a Node Anthony Dodd