• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create/modify an XML file using SAX?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
Could anyone plz tell me how to create/modify an XML file using SAX? I know how to read etc, but how to modify data using SAX?
Any help will be most appreciated.
Regards,
Felix
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Essentially, you have to fake/modify SAX events - this turns out to be fairly easy to do. The Cocoon project uses a "pipeline" that feeds SAX events from one processor to another and modifies them along the way, so you might look at that project at xml.apache.org. However there are a lot of fiddly details you have to get right.
Bill
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SAX is an XML parser API. It does not provide you with any functionality to modify XML documents.
There are plenty of alternative ways of creating and updating XML documents. For example have a look at JDOM.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you have to do to get a SAX application to write an XML document is handle all the events in terms of writing the content to a file. Nothing magic about it.
Elliot Rusty Harold's "Processing XML with Java" Chapter 8 SAX Filters is a gold mine of examples.
Bill
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic