This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Need Parser program to write elements into xml file..! Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Need Parser program to write elements into xml file..!" Watch "Need Parser program to write elements into xml file..!" New topic
Author

Need Parser program to write elements into xml file..!

chaitanya sai
Greenhorn

Joined: May 25, 2006
Posts: 2
Hi All,

I have one xml file like:
<EMPS>
<EMP>
<NAME>Chaitanya</NAME>
<ENO>E001</ENO>
<SEX>M</SEX>
</EMP>
</EMPS>

and my requirement is...

by using any java parser code like DOM or SAX..i have to add one more
<EMP></EMP> entry in xml file...for ex:

</EMP>
<NAME>Krishna</NAME>
<ENO>E002</ENO>
<SEX>M</SEX>
</EMP>

Is there any way to add entry into xml file by using parser program?
(because DOM and SAX provides ways to reading a xml file...)

Please provide me the valuable suggestions to do this task.

i will be so greatful to u if u get me java code...

waiting for ur valuable response..

Thanks in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35237
    
    7
Hello chaitanya-

Welcome to JavaRanch.

On your way in you may have missed that JavaRanch has a policy on display names, and yours does not comply with it; specifically, a first name and a last name are required. Please adjust it accordingly, which you can do right here. Thanks for your prompt attention to this matter.

As to your question, "parsing" refers to reading XML, not generating it. SAX won't help you much with modifying XML, but using DOM this is easily possible. Here is an example program for reading an XML file and creating a DOM Document object, through which you can access the XML elements, add new ones, and save the result to a different file.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Need Parser program to write elements into xml file..!
 
Similar Threads
Problem with parsing I need to insert...
xml experts help me SAX Parser in xml
Error while updating login-config.xml
Formating XML document.
onetomany - hibernateTemplate