This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding attributes to root tag

 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need Java code to read a large XML message from a database, add several attributes to the root tag, and send it out over a network. Ideally, I'd like to avoid having the entire message in core memory. Doesn't SAX allow parsing without loading the whole file? I'd appreciate some tips. The database and network stuff I can do, but the XML manipulation is baffling to me.
 
Paul Clapham
Sheriff
Pie
Posts: 20177
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A SAX filter is what you want here. There's a whole chapter of a book online that describes them:

http://www.cafeconleche.org/books/xmljava/chapters/ch08.html

I think you are hinting at what the author says in the first paragraph of that chapter: "In all of XML, I have found nothing quite so hard to understand yet easy to do as writing SAX filters."
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic