wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Inserting a node in an existing xml document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Inserting a node in an existing xml document" Watch "Inserting a node in an existing xml document" New topic
Author

Inserting a node in an existing xml document

indu mathikrr
Greenhorn

Joined: Jan 28, 2010
Posts: 1
Hi!

i need to insert a new element in an existing xml document.This is my sample xml document..




I'll get get the node name that has to be and its value and the position to add the node all in run time only.
I'm displaying the xml in a form display in a jsp page and i have a check box for every node. So when i click a node i'll display the elements that can be added under that corresponding node using the DTD of that xml.
Hereby i'm getting the node name its textvalue and Xpath..
I couln't get the xpath correctly and so i couln't add that element in the proper node.
Here is my code....
It adds the node name and node value but not in the correct location...It adds under the first <person> even if i select second <person>



i'm going wrong in the nodepath as i'm retrieving the nodepath as "/folks/person/name".. it cant identify the exact <person> and so it considers the first <person>

Can you give me any idea to solve this issue?

Thanks in advance,
Indu



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depending on which XML library you're using this thread will be moved to a sensible forum.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

"indu ss", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Also, please take the time to choose the correct forum for your posts. This forum is for questions on Servlets. For more information, please read this.

This post has been moved to a more appropriate forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inserting a node in an existing xml document
 
Similar Threads
Problem Overwriting XML Section
Overwriting a specific XML section
How to remove element in xml ?
Help regarding how to check the element entered is equal or not in xml file
making changes to an xml document...help needed!