javax swing html解析器没有拿起img标签

时间:2012-05-02 17:58:24

标签: java html swing html-parsing

此HTML:

<td height="79" valign="top" width="70">
            <a href="http://e.livinghuntington.com/HS?a=stuff" target="_blank" title="Follow us on Twitter: http://twitter.com/#!/HuntingtonLive"> link link link <img alt="Follow us on Twitter: http://twitter.com/#!/HuntingtonLive" border="0" height="79" src="http://webe.emv3.com/livinghuntington/images/tt.png" style="display:block;" width="70"/></a>
        </td>
</table>
<table>

和这段代码:

public void handleStartTag(Tag tag, MutableAttributeSet attr, int pos) {

     System.err.println("tag = " + tag);

给出这个输出:

tag = td
tag = a
tag = table

我尝试了各种测试策略:如果我嵌套链接(我甚至不知道它是否是有效的html),它会正确地获取内部链接。如果我从链接中拉出图像,它仍然不会拾取img。据我所知,从来没有拿过图像标签。代码或kludge是否存在错误,或者HTML解析器是否存在无法修复的问题(所以我需要将其丢弃并使用新的)?

1 个答案:

答案 0 :(得分:2)

问题是img是简单的标签,因此在startTag()下没有被选中。 handleSimpleTag()是要使用的处理程序。

相关问题