cancel
Showing results for 
Search instead for 
Did you mean: 

how to edit the existing data in the XML file from java programming.

Former Member
0 Kudos

Hi all

i am able to create XML file with the sample data as below from java programming.

i need sample code on how to edit the existing data in the XML file?

for example

<?xml version="1.0"?>

<mydata>

<data1>

<key1>467</key1>

<name1>Paul</name1>

<id1>123</id1>

</data1>

<data2>

<key2>467</key2>

<name2>Paul</name2>

<id2>123</id2>

</data2>

</mydata>

i am able to insert the data in the XML.

now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code

Regards

Sunil

[points will be always rewardable]

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

DOM, SAX, XSLT and many more are their to work with your scenario...

Following link will shed some light

http://www.developer.com/xml/article.php/10929_2108031_2

http://www.w3schools.com/

Regards

Ayyapparaj

Former Member
0 Kudos

I suggest you to use Dom4j

it easier to use and it pretty good performance!

Answers (1)

Answers (1)

ravindra_bollapalli2
Active Contributor
0 Kudos

hi

u need a parser or validate the xml file for to read the xml file from java coding u need for this

xml4j.jar u can download this file from here

http://www.alphaworks.ibm.com/tech/xml4j

or we can use the SAX(simple API for XML)

some sample applications for this

http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html

http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html

http://www.xml-training-guide.com/e-xml44.html

let me know u need any other info

bvr