read an write
posted 10 years ago
One way is to use XSLT to transform the document. Read up on the TrAX API to learn how to use it. What you'll do is create an XSLT stylesheet the writes the original XML adding the extra element. Another way is to use the SAX API and implement your writing directly as you read. That may be a little more simple for you but it does not scale well as you need to add more elements change elements, or remove elements. XSLT was designed for changing XML and I'd suggest that if your needs tend to grow.