73

I had created the xml document with xml version="1.0".

In that document I need to use the greater than symbol > and less than symbol <.

How should I include those symbols? It's not working.

&gt; and &lt; are not working for me.

Is there any special encoder for this?

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
praveenjayapal
  • 37,683
  • 30
  • 72
  • 72
  • 2
    You say that > is not working for you? Can you post some of your code? – nickf Dec 01 '08 at 12:59
  • 5
    "Not working" in what way? Be more specific (error message, etc) because > and < are indeed one of the two propers methods. – bortzmeyer Dec 01 '08 at 12:59
  • 2
    It is difficult to offer solutions when the problem statement is simply, "it doesn't work". Please [edit] your question to give a more complete description of what you expected to happen and how that differs from the actual results. See [ask] for hints on what makes a good explanation. – Toby Speight Oct 19 '16 at 16:14

3 Answers3

116

You need the Character Entity References

< = &lt;

> = &gt;

Greg
  • 316,276
  • 54
  • 369
  • 333
24

You can try to use CDATA to put all your symbols that don't work.

An example of something that will work in XML:

<![CDATA[
function matchwo(a,b) {
    if (a < b && a < 0) {
        return 1;
   } else {
       return 0;
   }
}
]]>

And of course you can use &lt; and &gt;.

Community
  • 1
  • 1
Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
  • 1
    you'll also have to put in javascript comments so you won't get a syntax error. /* <![CDATA[ */ ... /* ]]> */ – nickf Dec 01 '08 at 13:00
  • 1
    no, no you don't - the *value-of* of the node will not include the CDATA markup - try it – annakata Dec 02 '08 at 08:54
18

Use &gt; and &lt; for 'greater-than' and 'less-than' respectively

tonys
  • 3,855
  • 33
  • 39