I'm trying to find a html map in a HTMLDocument
:
<html>
<map name="imagemap"></map>
</html>
With hdoc
my HTMLDocument
, I tried the following to get the map but it keeps returning null
:
hdoc.getElement(hdoc.getDefaultRootElement(), HTML.Attribute.NAME, "imagemap")
Am I doing something wrong? How do I get the map?
You can't get the <map>
nodes with getElement
. They all get deleted by the HTML interpreter, even those in use.
Instead, use
((Hashtable) hdoc.getDocumentProperties().get("__MAP__")).get("#imagemap");
Unfortunately, the Map
you get from this is a package-private class, so you can't use the data unless you do some reflection.