Programmatic HTMLDocument generation using Java

前端 未结 9 2254
孤独总比滥情好
孤独总比滥情好 2021-02-14 03:34

Does anyone know how to generate an HTMLDocument object programmatically in Java without resorting to generating a String externally and then using HTMLEditorKit#read to parse i

9条回答
  •  轮回少年
    2021-02-14 04:15

    Basically you can insert html into your HTMLDocument using one of the insert methods, insertBeforeEnd(), insertAfterEnd(), insertBeforeStart(), insertAfterStart(). You supply the method with the html you want to insert and the position in the document tree that you want the html inserted.

    eg.

    doc.insertBeforeEnd(element, html);

    The HTMLDocument class also provided methods for traversing the document tree.

提交回复
热议问题