[jdom-interest] Confused ? I am

Kenworthy, Edward edward.kenworthy at exchange.co.uk
Fri Mar 30 01:01:25 PST 2001

Be gentle, this is my first post!

OK, I've been reading the O'Reilly book "Java and XML" and that's how I
found out about JDOM. I've built an application using JDOM and following the
book. However, I now what to modify the text content of an Element. Eg:

	Some text or other.

Now calling getText() on the Element gives me back "Some text or other." -
which is what I expected - however, calling setText() to change that text
actually wipes out the child element ! That is to say setText() and
getText() do not behave intuitively with respect to each other.

So I went and re-read the chapter on JDOM in Brett's book, and it seems that
getContent() and setContent() might do the job - but this is where it gets
confusing. Even though the book says these methods exist - they don't ! So I
decided to check which version of JDOM I have - it's beta 6. Now according
to the book (bottom of p205) "The reference implementation, contained within
the org.jdom.package, is a complete 1.0 working product, and is currently
available for download with the specification at http://www.jdom.org".

Ah ha! I thought, I have an out of date version. However checking
www.jdom.org it seems that beta 6 is the latest version and there is no
release 1.0, despite what Brett (one of the authors of the JDOM spec !) says
in his book. Confused ? I am !

So my questions are:
1. How do I change just the text part (eg what is returned by getText() of
an Element without wiping out the child elements, which setText(), does.
2. What's going on with the O'Reilly book. Was Brett beng optimistic when he
wrote it, expecting the 1.0 version to be available when it was published ?
3. What has happened to getContent() and setContent() ?

I'm feeling a bit like I am banging my head against a brick wall so any help
would be appreciated.


More information about the jdom-interest mailing list