Since you said you tried casting, I'll assume that the Document
instance you have is not a org.apache.html.dom.HTMLDocumentImpl
. Two things that might be worth a shot:
1) The getImages()
method is in fact defined on the interface org.w3c.dom.html.HTMLDocument
, which is more likely to be implemented by whatever type of Dom document you have. Thus, you should be able to do something like:
if (doc instanceof HTMLDocument) {
images = ((HTMLDocument) doc).getImages();
}
2) If that doesn't work, the getImages()
method is really not going to do anything much fancier than:
images = doc.getElementsByTagName("img");