Q:

How to print an HTML tag in a JTextPane with html content type in Java

I am creating an XML editor with Java and I am using JTextPanes to show the content of the XML.
The content type of the JTextPanes is "text/html" so it is skipping all of the XML tags that I want to appear in the pane.
Here is most of the JTextPane class:
public class Label extends JTextPane {
    private static final long serialVersionUID = 6151945111760925061L;

    public Label(String text) {
        setContentType("text/html");
        setText(StringOperations.toHtml(text));
        setEditable(false);
        setBackground(null);
        setBorder(null);
        setFont(new Font("Eras Bold ITC", Font.PLAIN, 11));
    }

}

Here is the method that converts the plain text to html.
public static String toHtml(String text) {
    return ("<html>" + text + "</html>");
}

So for example when I insert:
 "<resource>4</resource>"
The output is "4".
What I want is for the output to be
"<resource>4</resource>".
I tried doing:
return ("<html>" + text.replace("<","/<") + "</html>");
return ("<html>" + text.replace("<","\"<\"") + "</html>");

But the tags are still unreadable.
Could you tell me how can I escape the '<' and '>' characters?

A:

Need to create custom EditorKit and set it to JTextPane,
for example : 
https://www.boplicity.nl/knowledgebase/Java/Xml+syntax+highlighting+in+Swing+JTextPane.html

