aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "read an write" Watch "read an write" New topic
Author

read an write

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 250
hi

i need to read and write a xml file similar to



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


thanks
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="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: read an write