Girish Patel
Girish Patel

Reputation: 1275

How to get Tag value from HTMl code in android?

I am doing RSS parsing by SAX parser and i am getting Description in this format :

<description><![CDATA[<div><b>Start Time:</b> 12/19/2010 6:30 PM</div>

<div><b>End Time:</b> 12/19/2010 10:00 PM</div>

<div><b>Description:</b> Break Guinness World Records of arda</div>

<div><b>Type of Event:</b> <a onclick="OpenPopUpPage('http://www.example.com/_layouts/listform.aspx?PageType=4&ListId={5368B20F-2E1F-4984-9308-3E46442B2336}&ID=79&RootFolder=*', RefreshPage); return false;" href="http://www.example.com/_layouts/listform.aspx?PageType=4&ListId={5368B20F-2E1F-4984-9308-3E46442B2336}&ID=79&RootFolder=*">Aspire closed stadium</a></div>

<div><b>Localization Data:</b> &lt;data&gt;&lt;item field=&quot;Title&quot; lang=&quot;ar-SA&quot;&gt; Break record &lt;/item&gt;&lt;item field=&quot;Description&quot; lang=&quot;ar-SA&quot;&gt;&amp;lt;P align=right&amp;gt;Break record &amp;amp;nbsp;  9/12/2010 Break record    &quot; National  &quot;  Men Poetry Activities . &amp;lt;/P&amp;gt;&lt;/item&gt;&lt;/data&gt;</div>

<div><b>LocationInInteractiveMap:</b> Don&#39;t Show</div>

<div><b>Latitude:</b> 25.266024</div>

<div><b>Longitude:</b> 51.443814</div>

<div><b>EventLogo:</b> <img alt="" src="/SiteCollectionImages/Event%20Images/Default.png" style="BORDER: 0px solid; "></div>

]]></description>

so how i am getting tag value from this html code?

Upvotes: 0

Views: 3361

Answers (2)

Paresh Mayani
Paresh Mayani

Reputation: 128428

Where you want to display this Description value? If you want to display it inside the TextView then write:

TextView foo = (TextView)findViewById(R.id.foo);
foo.setText(Html.fromHtml(description));

Or

You can load the Description string value inside the WebView:

 webview.loadData(description, "text/html", null);

Upvotes: 1

user370305
user370305

Reputation: 109247

Try this,

 Html.fromHtml(String source)
 Returns displayable styled text from the provided HTML string.

And

Html.fromHtml  (String source, Html.ImageGetter imageGetter, Html.TagHandler tagHandler)

Since: API Level 1

Returns displayable styled text from the provided HTML string. Any tags in the HTML will use the specified ImageGetter to request a representation of the image (use null if you don't want this) and the specified TagHandler to handle unknown tags (specify null if you don't want this).

Be sure : Have your source markup be valid HTML? 

Upvotes: 1

Related Questions