How can I parse nested elements in SAX Parser in java?
问题 I want to parse an XML file using SAX parser in java with this format : <Deals> <Deal> <id> 10</id> <title> title </title> <city> <id> 1 </id> ... </city> </Deal> ... </Deals> I have a problem to distinguish between the id element of Deal Node and the id element of the city node. 回答1: One thing you can do (I've seen it around and used it -- I'm not certain it's the most efficient or effective way, but it works) is to maintain some state in your parser, whether that be a defined set of states,