Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding attributes to root tag

 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 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
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • 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."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic