This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Adding attributes to root tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Adding attributes to root tag" Watch "Adding attributes to root tag" New topic

Adding attributes to root tag

Greg Charles

Joined: Oct 01, 2001
Posts: 2969

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

Joined: Oct 14, 2005
Posts: 19973

A SAX filter is what you want here. There's a whole chapter of a book online that describes them:

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."
I agree. Here's the link:
subject: Adding attributes to root tag
It's not a secret anymore!