how to place < symbol in xml file which is to be read by the java program?

java, sql, xml

Solution

You need to escape using XML entities:

- `&` encode as `&amp;`

- `<` encode as `&lt;`

Technically, you don't need to escape the following, but it is common to do so:

- `>` encode as `&gt;`

- `"` encode as `&quot;`

- `'` encode as `&apos;`

For more info, see this Wikipedia article for more

Problem

I am placing an SQL query(which contains < symbol) inside xml file and i am trying to read that query in a java program. But it is displaying the exception "org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup." can any one help me how to fix the above issue?

Original source