Capturing values ​​in XML elements in Java

I am studying how I can get values ​​from specific XML nodes in an XML file that I have. In my application, I have the whole XML file in a string, and I want to get specific information from there. I heard a little about DOM and SAX, but I don’t know exactly where to start. Any help?

+1
source share
3 answers

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

+4
source

You can use XPath ( example ), or you can use DOM or SAX (as you mentioned). You can view my answer (how to get the value of an XML element using Java?) On SO.

0

Well, there is also Xstream http://x-stream.imtqy.com/index.html

This will allow you to do both directions (object in xml and xml for object). Here is a “two minute tutorial”: http://x-stream.imtqy.com/tutorial.html

0
source

All Articles