Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding elements to a dom tree

Posted on 2004-04-28
7
Medium Priority
?
310 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 400 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…
Suggested Courses

598 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