2

I got the following String as response when I post the url via HttpPost. My problem is how can I parse this string.

<?xml version="1.0" encoding="UTF-8"?>

<opml version="1">

    <head>
    <status>200</status>
        </head>

    <body>

<outline type="object" text="account">

<account>

  <guide_id>u36710162</guide_id>

  <username>xyz</username>

  <session_id>9d28d854-bd31-4bba-9a5f-4e5cd88edaac</session_id>

  <first_name />

  <last_name />

  <email>xyz@gmail.com</email>

</account>

</outline>

    </body>

</opml>

How can I get the status, guide_id, username, session_id, first_name, last_name and email from this string.

Thanks in Advance ...!!!

Android Boy
  • 4,335
  • 6
  • 30
  • 58

1 Answers1

1

It is a XML format response. You can parse it by SAXParser, DOMParser or Xmlpullparser.

About status that you can get it from HTTP itself

HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httpRequest);
response.getStatusLine().getStatusCode()

Note: Consider <account> as your parent tag.

Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • can you give any sample code ...!!! I want to be parse status also, bcz by this I would be get idea the response is correct or not ...!!! – Android Boy Jun 08 '12 at 05:28
  • Thanks a lot. Now I have done it. But the posted code by you I have already done. But the given link is very useful. – Android Boy Jun 08 '12 at 06:22