0

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.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
Hany
  • 1,146
  • 4
  • 18
  • 26

4 Answers4

2

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.

pugmarx
  • 7,323
  • 3
  • 30
  • 40
1
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.

Svisstack
  • 16,203
  • 6
  • 66
  • 100
1

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

Community
  • 1
  • 1
Niels Bom
  • 8,728
  • 11
  • 46
  • 62
0

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"?>
shasi kanth
  • 6,987
  • 24
  • 106
  • 158