Solved

Adding elements to a dom tree

Posted on 2004-04-28
7
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Custom Java Application connects to database: Which one of the 20? 4 58
ejb entity bean example 2 57
Java array sort 10 62
maximize the sum of fractions 33 74
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

734 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