File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Interview Guide this week in the Jobs Discussion 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>")));
I agree. Here's the link:
subject: How to pasrse XML string quickly in java
It's not a secret anymore!