B
Bill Tschumy
I am parsing an HTML file using ParseDelegator and a ParserCallback. I am
trying to get the document title and the HREF links. The ParserCallback is
successfully getting the HREF, so I know it is basically working. However,
when I try to get the title, I always get back null. Here is the relevant
code of the ParserCallback subclass. Anyone have any clue as to what I'm
doing wrong?
public void handleStartTag(HTML.Tag tag,
MutableAttributeSet attrSet, int pos)
{
if (tag == HTML.Tag.TITLE)
{
urlTitle = (String)attrSet.getAttribute(HTML.Attribute.TITLE);
System.out.println("attrSet: " + attrSet); // prints ""
System.out.println("found title: " + urlTitle); // prints null
}
if (tag == HTML.Tag.A)
{
// This successfully gets the target URL
String targetURLStr =
(String)attrSet.getAttribute(HTML.Attribute.HREF);
}
}
trying to get the document title and the HREF links. The ParserCallback is
successfully getting the HREF, so I know it is basically working. However,
when I try to get the title, I always get back null. Here is the relevant
code of the ParserCallback subclass. Anyone have any clue as to what I'm
doing wrong?
public void handleStartTag(HTML.Tag tag,
MutableAttributeSet attrSet, int pos)
{
if (tag == HTML.Tag.TITLE)
{
urlTitle = (String)attrSet.getAttribute(HTML.Attribute.TITLE);
System.out.println("attrSet: " + attrSet); // prints ""
System.out.println("found title: " + urlTitle); // prints null
}
if (tag == HTML.Tag.A)
{
// This successfully gets the target URL
String targetURLStr =
(String)attrSet.getAttribute(HTML.Attribute.HREF);
}
}