wood burning stoves*
The moose likes XML and Related Technologies and the fly likes How to pasrse XML string quickly in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to pasrse XML string quickly in java" Watch "How to pasrse XML string quickly in java" New topic

How to pasrse XML string quickly in java

srihari paturi

Joined: Nov 25, 2007
Posts: 2
Hi all,

Could you please tell me how to parse xml string in java.
Ex. I have a string like this
String str ="<A><b>10</b>
how to get the values of it?

Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You can use SAX or DOM for that. DOM is easier to use than SAX. You can also you dom4j, which is easier than the normal DOM.

Do some google search. There are lot of tutorials on how to parse XML using DOM or SAX.

Good luck.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Kamal Ahmed
Ranch Hand

Joined: Feb 15, 2005
Posts: 91
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();

DocumentBuilder dBuilder = dFactory.newDocumentBuilder();

Document doc = dBuilder.parse(new InputSource(new StringReader("<test>test</test>")));
wood burning stoves
subject: How to pasrse XML string quickly in java
Similar Threads
render string array in xslt
How to get a part of xml document in String format
help needed with sax parser
How to Marshal special chars from Java to XML (&, etc)
Get data for child using jdom