0

Hey I am working in json response with html tag in kotlin. I don't understand how to parse html tag in response. I tried to work with retrofit and moshi. My response will look like this

Response

{
  "items": [
    {
      "id": "1",
      "date": "2021-11-01",
      "title": "<html><head><style>body {
   color: black;
}
</style></head><body><h1 id="sample-markdown">Sample Markdown</h1>
<p>This is some basic, sample markdown.</p>
<h2 id="second-heading">Second Heading</h2>
<ul>
<li>Unordered lists, and:<ol>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ol>
</li>
<li>More</li>
</ul>
<blockquote>
<p>Blockquote</p>
</blockquote>
<p>And <strong>bold</strong>, <em>italics</em>, and even <em>italics and later <strong>bold</strong></em>. Even <del>strikethrough</del>. <a href="https://markdowntohtml.com">A link</a> to somewhere.</p>
<p>And code highlighting:</p>
<pre><code class="lang-js"><span class="hljs-keyword">var</span> foo = <span class="hljs-string">'bar'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">baz</span><span class="hljs-params">(s)</span> </span>{
   <span class="hljs-keyword">return</span> foo + <span class="hljs-string">':'</span> + s;
}
</code></pre>
<p>Or inline code like <code>var foo = &#39;bar&#39;;</code>.</p>
<p>Or an image of bears</p>
<p><img src="http://placebear.com/200/200" alt="bears"></p>
<p>The end ...</p>
</body></html>"
    }
  ]
}

I want to show title in textview.

enter image description here

Is it possible in android we can do?

Kotlin Learner
  • 3,995
  • 6
  • 47
  • 127

1 Answers1

0

You can render those html codes into a text view, try to use this library to do that. https://github.com/SysdataSpA/SDHtmlTextView

Edit: You can also use WebView to render html.