Gajendra Bang
Gajendra Bang

Reputation: 3583

HTML tags inside xml, how to parse correctly in Android?

I need to parse this xml. I am trying dom parser.

I am not able to put html tags in CDATA becuase the result is fetched from a webservice.

<?xml version="1.0" encoding="UTF-8" ?>
<sendgps>
<pin>1231771972</pin>
<deviceid>9774d56d682e549c</deviceid>
<balance>0.50 </balance>
<msg><b>This is a</b> test. <a href="http://www.google.com">Click</a> to go to website<br></msg>
<errorcode>0</errorcode>
</sendgps>

Upvotes: 1

Views: 616

Answers (2)

Roman Minenok
Roman Minenok

Reputation: 9368

I faced similar problem. What I am doing is

  1. Parse XML fields with SAX parser (you can use DOM also)
  2. Strore fields contained in HTML in the separate fields inside my objects each one representing an entity inside my XML.
  3. Parse HTML fields with JSoup. http://jsoup.org/ It's very handy and doing its job well. You can get more familiar with it through their cookbook: http://jsoup.org/cookbook/

Upvotes: 0

SLaks
SLaks

Reputation: 887295

You should complain to the webservice.

If they continue lying about their output format, use JSoup.

Upvotes: 2

Related Questions