This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes how can i parse? 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 can i parse?" Watch "how can i parse?" New topic

how can i parse?

Suhas Madap
Ranch Hand

Joined: Aug 29, 2006
Posts: 52
How can i parse a XML which is in String i.e.
String str="<?xml version="1.0" encoding="UTF-8"?>
<title>This is my first Xml program</title>
<prod id="15-12" media="internet"></prod>

<chapter>Introduction to XML
<para>what is XML</para>
<para>How to code XML</para>

<chapter>Intro to syntax
<para>Elements of XML</para>
<para>Attribute of XML</para>

So which parser will be a good option, SAX or DOM?

Thank you,<br /> <br />Suhas K Madap<br /> <br />If you understand what you're doing, you're not learning anything."
Paul Clapham

Joined: Oct 14, 2005
Posts: 19433

To parse XML from a string, you do something like this:As for which parser to use, that depends on several things. Have you read any Java XML tutorials yet? Here's a link to one:
Suhas Madap
Ranch Hand

Joined: Aug 29, 2006
Posts: 52
ThanQ paul. this will help me. ThanQ once again.
I agree. Here's the link:
subject: how can i parse?