Hany
Hany

Reputation: 1136

special characters in XML file

I am using an XML file in my application. I want to write my query string into the XML file and then read it from the application side. My query is like that:

select * from employee
where salary < 10000

I faced this problem: when I write this character '<' I got an error. How can I use it in my XML? Thanks.

Upvotes: 0

Views: 3553

Answers (4)

shasi kanth
shasi kanth

Reputation: 7102

In order to allow any special characters to be written in your xml file, make sure that you have the xml encoding defined at the top, like:

<?xml version="1.0" encoding="UTF-8"?>

Upvotes: 0

pugmarx
pugmarx

Reputation: 7433

It's been a while since I ventured into queries. But, maybe you can use CDATA. Embed the special chars within it. This way the parser should skip it. See this: http://www.w3schools.com/xml/xml_cdata.asp.

Upvotes: 2

Niels Bom
Niels Bom

Reputation: 9417

You have to escape the "<" character using

&lt;

Somebody else beat me to it :)

You have to escape other characters too, see this question Invalid Characters in XML

Upvotes: 1

Svisstack
Svisstack

Reputation: 16656

select * from employee where salary &lt; 10000

Or you can use some XML Document Writer then you don't must write this string secure function by hand, your XML Document Writer code do this, and secure more characters who not allowed in XML.

Upvotes: 1

Related Questions