Solved

Adding elements to a dom tree

Posted on 2004-04-28
7
301 Views
Last Modified: 2013-11-24
I'm adding elements to a dom tree and i can add to the head of a node using the code:

Element firstElement = (Element) nl.item(1);
firstElement.getParentNode ().insertBefore (newNode, firstElement);

This will add the element <init-param> to the start of the servlet as follows:
<servlet>
  <init-param>
   <param-name>param1</param-name>
   <param-value>param1</param-value>
  </init-param>
  <servlet-name>servletA</servlet-name>
  <servlet-class>servlets.servletA</servlet-class>
</servlet>

This is wrong though how can i add it so that it will be the last in servlet like:

<servlet>
  <servlet-name>servletA</servlet-name>
  <servlet-class>servlets.servletA</servlet-class>
  <init-param>
   <param-name>param1</param-name>
   <param-value>param1</param-value>
  </init-param>
</servlet>
0
Comment
Question by:liamgannon
  • 4
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10943653
How about

servletRoot.appendChild

?
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 100 total points
ID: 10943657
Or in your code case

firstElement.getParentNode().appendChild
0
 

Author Comment

by:liamgannon
ID: 10943692
will i then be the last element of <servlet>?
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 86

Expert Comment

by:CEHJ
ID: 10943704
Should be yes
0
 
LVL 92

Expert Comment

by:objects
ID: 10943985
0
 

Author Comment

by:liamgannon
ID: 10944280
Cheers CEHJ ;-)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10944440
:-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now