Using SAX to edit an xml file

Posted on 2005-03-01
Medium Priority
Last Modified: 2013-11-23
I am able to parse an xml file, and retrieve data element by element for the program to use, but is it possible using SAX to write back to the xml file?

What I would like to be able to do is add elements to it, or edit attribute values of the elements currently there.  A few tutorials I have read say edit it as a text file, but I'm hoping there is a way with a SAX parser to just insert new elements, and it'll do the rest.  I am using the SAXParserFactory.  Can anyone give me a rough outline of whether its possible?
Question by:ant84
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
LVL 35

Accepted Solution

TimYates earned 375 total points
ID: 13430194
You'd have to build up your new document as text as you parse through the current one, and add things in...

then dump this new XML document over the top of the old one (as a text file)

I *think* :-/

Author Comment

ID: 13430470
Thanks for the quick reply, thats what a couple of tutorials seemed to suggest but I was surprised there wasn't a better method.  I will sit out a little longer for anyone else, but if not will give you the points.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 7 hours left to enroll

771 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