I'm looking into how I can get values from specific XML nodes in an XML file that I have. In my application, I have the entire XML file in a string, and I want to grab the specific information from there. I've heard a little bit about DOM and SAX, but I don't exactly know whe开发者_如何转开发re to start. Any help?
One of the easiest ways is to use xPath. Here's a tutorial.
You can either use XPath (example) or you can use DOM or SAX (as you mentioned) You can view my answer here (how to retrieve element value of XML using Java?) on SO.
Well, there is also Xstream http://x-stream.github.io/index.html
It let´s you do both directions (object to xml, and xml to object). Here is the "two minutes tutorial": http://x-stream.github.io/tutorial.html
精彩评论