I am using the dom4j to create XML string in Java. There is a sentence such as "the age > 10 and number < 11."
I do the following code
String wholeText = "the age > 10 and number < 11.";
Element text = section.addElement("text");
text.addText(wholeText);
when I show the text content, it was converted as
"the age > 10 and number < 11."
the "<" and ">" symbol was converted to the html string.
Does any way to keep the original symbol when I add text into XML tag using dom4j?
thanks a lot
Some characters (especially <
) have to be escaped this way unless you wrap the content in a CDATA section.
To make it a CDATA section from dom4j, you could use
String wholeText = "the age > 10 and number < 11.";
Element text = section.addElement("text");
text.addCDATA(wholeText);