aspose file tools*
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
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
Author

How to pasrse XML string quickly in java

srihari paturi
Greenhorn

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>
<C><c>hai</c></C>
</A>
how to get the values of it?

Thanks
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>")));
 
 
subject: How to pasrse XML string quickly in java