Two Laptop Bag
The moose likes XML and Related Technologies and the fly likes read an write 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 "read an write" Watch "read an write" New topic

read an write

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 251

i need to read and write a xml file similar to

what is the best way to add an element "turn" in this file?

Clifton Craig
Ranch Hand

Joined: May 26, 2006
Posts: 103
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.

Holla at me...<br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: read an write
It's not a secret anymore!