I have an XML file, I need to search for a specific tag in it and update it's value. The problem is that, using Sax parser is "must". I have to find these tags by using Sax Parser "only", dom stax j4dom dom4j parsers are out of consideration.
Can I accomplish this task by converting my xml file to a string and parse it by using sax parser and append the new value by StringBuilder
object? Would it be okay? Or what would you recommend?
This is a working code, just add missing imports. It uses SAX and changes
<name>user1</name>
to<name>user2</name>
. If you figure out how it works plus read SAX API you can do anything with your xml. Note that SAX had been considered the most efficient xml parser until StAX came into beingSAX parser is not a bad choice if time is not a consideration and memory is.