I'm parsing html using Html.fromHtml(). My problem is that my html text has youtube embeded links (basically <iframe>
tags)
So, since Html class does NOT support <iframe>
tag, I need to define my own TagHandler to handle it. What I'm trying to do is to convert the <iframe>
to a regular <a>
tag so that it can be rendered correctly.
//convert this
<iframe src="http://www.youtube.com/embed/xAEdMI2ZE88" frameborder="0" width="560" height="315"></iframe>
//To this
<a href="http://www.youtube.com/embed/xAEdMI2ZE88">Click to Watch</a>
My problem is that I couldn't find a way to get the src
link of the youtube from the <iframe>
tag.
Here is my TagHandler's handleTag()
method:
@Override
public void handleTag(boolean opening, String tag, Editable output, XMLReader xmlReader) {
if (tag.equals("iframe")) {
if(opening) {
output.append("<a href=");
//How to get YouTube video link and append it?
}
else {
output.append("Click To Watch</a>");
}
}
}
Thanks in advance.