FW: [jdom-interest] Jdom AddChild

Simphoukham, Southin Southin.Simphoukham at westgroup.com
Fri Apr 6 10:16:00 PDT 2001


Jason,

Thanks for the information.  I did check it out.  I am slowly moving through
the examples but still confused.

I would like to know how you would write the following using jdom

<Bears>
	<Northern>
		Grizzlie
	</Northern>
	<Southern>
		Black
	<Southern>
	<Western>
		Kodiak
	</Western>
</Bears>

The root.addContent(new Element(something, something));

 root.addContent(new Element("Unix", "unix"));
 root.addContent(new Element("Hello","helloagain","bye"));
 XMLOutputter fmt = new XMLOutputter();
 fmt.output(doc,out);

gives me this:

<Unix xmlns="unix" />
<helloagain:Hello xmlns:helloagain="bye" />

when I want this
	
<Unix>
	<helloagain>
		helloagain bye
	</helloagain>
</Unix>

Thanks,

Southin Simphoukham


-----Original Message-----
From: Jason Hunter [mailto:jhunter at collab.net] 
Sent: Friday, April 06, 2001 11:47 AM
To: Simphoukham, Southin
Cc: 'jdom-interest at jdom.org'
Subject: Re: [jdom-interest] Jdom AddChild


"Simphoukham, Southin" wrote:
> 
> Hi,
> 
> I am new to using Jdom so I am using the Java and XML by O'Reilly as a
> guide.   I am working on creating an XML file from scratch page 369.  

See the JDOM faq at jdom.org and look for discussion about the book
being out of date.

> What
> happened to the Element.addChild method?  I assume it is depreciated.  How
> can I add a child element?  Any examples would be great.

The method you want is addContent().

-jh-



More information about the jdom-interest mailing list