1

In an open page loaded frame:

 <iframe id="wikipedia" src="http://en.wikipedia.org"></iframe>

Trying to get to the content:

Document document = webEngine.getDocument();
Element elementById = document.getElementById("wikipedia");
System.out.println(elementById.getTextContent());

But do not achieve results ...

Alexander Cyberman
  • 2,114
  • 3
  • 20
  • 21

1 Answers1

4

The following code works fine with javafx2:

Document doc = webEngine.getDocument();
HTMLIFrameElement iframeElement = (HTMLIFrameElement) doc.getElementById("wikipedia");
Document iframeContentDoc = iframeElement.getContentDocument();
Element rootElement = iframeContentDoc.getDocumentElement();
System.out.println(rootElement.getTextContent());
GregKo
  • 159
  • 1
  • 5