As others have mentioned, using an XML library is the easiest way. If you do want to escape yourself, you could look into StringEscapeUtils
from the Apache Commons Lang library.
More Related Contents:
- Producing valid XML with Java and UTF-8 encoding
- Normalization in DOM parsing with java – how does it work?
- In Java, how do I parse XML as a String instead of a file?
- How to convert XML to java.util.Map and vice versa?
- How to group a 3×3 grid of radio buttons?
- Spring schemaLocation fails when there is no internet connection
- Using JAXB to cross reference XmlIDs from two XML files
- java.util.Date to XMLGregorianCalendar
- What is the best/simplest way to read in an XML file in Java application? [closed]
- Merge Two XML Files in Java
- Generate Java classes from .XSD files…?
- Android change Material elevation shadow color
- Parsing XML with XPath in Java [duplicate]
- Is there a more elegant way to convert an XML Document to a String in Java than this code?
- File was loaded in the wrong encoding:’UTF-8′ in IntelliJ IDEA
- @XmlPath has no impact during the JAXB Marshalling
- Java + Mysql UTF8 Problem
- How do you customize how JAXB generates plural method names?
- How to strip whitespace-only text nodes from a DOM before serialization?
- XML Node to String in Java
- Byte and char conversion in Java
- How to validate XML against XSD 1.1 in Java?
- Java : Convert formatted xml file to one line string
- How to use Special Chars in Java/Eclipse
- Java/JAXB: Unmarshall XML attributes to specific Java object attributes
- Best method to parse various custom XML documents in Java
- Is there a SaxParser that reads json and fires events so it looks like xml
- Unable to read xml with namespace prefix using DOM parser
- transformer.setOutputProperty(OutputKeys.ENCODING, “UTF-8”) is NOT working
- Creating an XML document using namespaces in Java