Chiggins
Chiggins

Reputation: 8397

Grabbing values in XML elements in Java

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 where to start. Any help?

Upvotes: 1

Views: 1255

Answers (3)

raspayu
raspayu

Reputation: 5139

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

Upvotes: 0

Buhake Sindi
Buhake Sindi

Reputation: 89169

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.

Upvotes: 0

Boris Pavlović
Boris Pavlović

Reputation: 64632

One of the easiest ways is to use xPath. Here's a tutorial.

Upvotes: 4

Related Questions