Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 07:10 AM
chiry@csua.berkeley.edu
Guest
 
Posts: n/a
Default jdom, adding child at specific location?


Is there a way to make Element.addContent add the content at a
specific location?

I need to update an existing jdom object in memory, by adding/removing
some elements. problem is, addContent() always add at the end, and as
a result the resulting XML object doesn't validate against the XSD
file.

Is there a way to add an element at a specific location?

Thanks.

Raymond
  #2  
Old July 20th, 2005, 07:11 AM
Keith A. Lewis
Guest
 
Posts: n/a
Default Re: jdom, adding child at specific location?

chiry@csua.berkeley.edu writes in article <bjtl91$1rtr$1@agate.berkeley.edu> dated Fri, 12 Sep 2003 23:36:01 +0000 (UTC):[color=blue]
>
>Is there a way to make Element.addContent add the content at a
>specific location?[/color]

No, not AFAIK.
[color=blue]
>I need to update an existing jdom object in memory, by adding/removing
>some elements. problem is, addContent() always add at the end, and as
>a result the resulting XML object doesn't validate against the XSD
>file.
>
>Is there a way to add an element at a specific location?[/color]

Yes. You can use Element.getContent() to get the content as a List, then use
List.add(int, Object) to insert the new content wherever you see fit.

Caution -- You can add any object to the content this way, only some of
which are valid in JDOM.

--Keith Lewis klewis$mitre.org
The above may not (yet) represent the opinions of my employer.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles