How can I display an XML Document in a JEditorPane?
Created May 4, 2012
Sandip Chitale You will have to write a custom
subclass of javax.swing.text.StyledEditorKit and also implement the javax.swing.text.ViewFactory.
Please look into the
javax.swing.text.html.HTMLEditorKit
and the
javax.swing.text.html.parser
for how to build an editor kit and the parser.
I think SAX XML parser (call back based) may work better. HTMLEditor kit is based on a callback parser. SAX works better because the javax.swing.text already has it's own object model (javax.swing.text.Document interfaces and javax.swing.text.StyledDocument class). This however does not mean you cannot use DOM parser, only thing is you will have to do more work to integrate DOM (document object model) into the text packages view system.