Vadim Gritsenko wrote:
Martin Bischoff wrote:
By debugging in Eclipse I found out that the content of the element
"Name" hast been splitted up into two child elements of the type
TextImpl. So, by using the getFirstChild() method I only get one part
of it.
AFAIU, this is normal mode of operation for XML parsers and DOM / SAX.
They can always split text into multiple TextNodes or character() events
as they want it. I'm not sure there is way around this; I think you
should collect all consecutive TextNodes and combine them.
Vadim
There's a normalize() method in org.w3c.dom.Node that solves
this problem, putting all Text nodes into one. Description:
Puts all Text nodes in the full depth of the sub-tree underneath this
Node, including attribute nodes, into a "normal" form where only
structure (e.g., elements, comments, processing instructions, CDATA
sections, and entity references) separates Text nodes, i.e., there are
neither adjacent Text nodes nor empty Text nodes. This can be used to
ensure that the DOM view of a document is the same as if it were saved
and re-loaded, and is useful when operations (such as XPointer
lookups) that depend on a particular document tree structure are to be
used. In cases where the document contains CDATASections, the normalize
operation alone may not be sufficient, since XPointers do not
differentiate between Text nodes and CDATASection nodes.
Murray
......................................................................
Murray Altheim http://kmi.open.ac.uk/people/murray/
Knowledge Media Institute
The Open University, Milton Keynes, Bucks, MK7 6AA, UK .
"Peoples' primary requirement is that some kind of coherence be
provided. Stories give people the feeling that there is meaning,
that there is ultimately an order lurking behind the incredible
confusion of appearances and phenomena that surrounds them. This
order is what people require more than anything else; yes, I
would almost say that the notion of order or story is connected
with the godhead. Stories are substitutes for God. Or maybe the
other way round." -- Wim Winders