Hi,
I'm trying to develop a linkchecker, the HTML text I'm using it on though has a few lines such as this:

<li><a href="PhD/refs.html"> <b> References </b> </a> section of  PhD 
<li><a href="WWM/refs.html"> <b> References </b> </a> section of  WWM proposal

which aren't being picked up by my linkchecker. The handleText part of my link checker looks like this:

public void handleText(final char[] data, final int pos) { }
		
public void handleStartTag(Tag tag, MutableAttributeSet attribute, int pos) 
{
	if (tag == Tag.A) 
	{
	String address = (String) attribute.getAttribute("href");	list.add(address);
	System.out.println(address); 
	}
}

but it's not picking up the attributes labelled by "href". Can any-one tell me why? Please let me know if I have to add the rest of my code?

Any help much appreciated!

Try this:

String address = (String) attribute.getAttribute(Attribute.HREF);

instead of:

String address = (String) attribute.getAttribute("href");

Hope it helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.