Hi,
You should use DocumentBuilderFactory, DocumentBuilder and Document
classes.
Here you have an example.
URL url = new URL("http://...");
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.connect();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(urlConnection.getInputStream());
doc.getDocumentElement().normalize();
NodeList nodeLst = doc.getElementsByTagName("categories");
for (int i = 0; i < nodeLst.getLength(); i++)
{
Node currentNode = nodeLst.item(i);
...
}
You should do it in an AsyncTask or Runnable.
Regards,
On Aug 1, 9:29 am, Hari <[email protected]> wrote:
> Plz, Anyone can please help me with parsing an XML String in
> Android???
>
> Here is the Xml file which has to be accepted as a string and display
> the contents of this xml code??
>
> <?xml version='1.0' encoding='iso-8859-1'?>
> <categories>
> <category id="1">
> <name>Real Estate</name>
> </category>
> <category id="2">
> <name>Hospitals</name>
> </category>
> <category id="3">
> <name>Gifts</name>
> </category>
> <category id="4">
> <name>Domestic Help</name>
> </category>
> </categories>
>
> Plz help me out..
> I'm extremely new to ANdroid development...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en