Reputation: 2515
I am creating an XML file using Java and am then reading the data from it too. The data I am adding as text node contains <p>
at several places, but as soon I try to read it, the string terminates on encountering <. What am I doing wrong? Would using escape sequence be helpful.?
Upvotes: 0
Views: 883
Reputation: 72069
You could use StringEscapeUtils.escapeXml()
from Apache Commons Lang to do escaping. However you shouldn't need to deal with escaping if you're using any library to read and write your XML. If you're constructing the XML entirely with your own strings then you should reconsider that approach.
Upvotes: 0
Reputation: 7689
You need to use entities for < and > as they are reserved characters. Use <
and >
to replace the angle brackets.
XML has other reserved characters like & also.
Upvotes: 1