Two Laptop Bag*
The moose likes XML and Related Technologies and the fly likes append an element to a text node using jdom? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "append an element to a text node using jdom?" Watch "append an element to a text node using jdom?" New topic
Author

append an element to a text node using jdom?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello,
I just started using JDOM.
It seems a Text node can only append a Text node using JDOM?
I try to append an element to a text node like the following:

Inside <parent> element, <anotherChild> element already exists,
if I want to add the second line containing a textr node and
a <child> node with content, how can I do it?
thanks,
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
What happens is actually the following:

In clear, you don't have the notion of a "line" in XML. In the above XML code, parent has three children, namely the element anotherChild, a text node with the content "I am a child:", and finally another element called child.
The XML document above could be created with the following code:

I hope it helps
[ December 23, 2003: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks,
Sorry, I did not make it clear.
My intention was to put two nodes together nomatter its a
a text node or element. Its possible there
are other nodes after <child>

In order to do that, should I remove text node first, then
add it and <child> element together to <parent>?
Is there an easy way to do that?
thanks
 
 
subject: append an element to a text node using jdom?