Get the text content of individual elements from an HTMLDocument

I have a jTextPane that has HTMLEditorKit installed as a standard Kit editor . Calling getDocument on jTextPane returns an HTMLDocument . I can go through this document by navigating through the elements, but I cannot find a way to get the text content of the individual elements. I know that there is a getTextContents () element in the DOM for each element, but I do not work with the W3C DOM.

+4
source share
1 answer

When you cross the ElementIterator document shown here , use getStartOffset() and getEndOffset() for each Element to calculate the parameters needed to call getText() .

+3
source

Source: https://habr.com/ru/post/1399695/


All Articles