tags:

views:

4343

answers:

4

Hi friends,

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?

Please help me.

+1  A: 

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

tonys
+5  A: 

You need the Character Entity References

< = &lt;

> = &gt;

Greg
A: 

CDATA is a better general solution.

annakata
I disagree. If you were just writing a paragraph and wanted to say "the number of results was > 100", then > would be MUCH simpler.
nickf
Hardly. CDATA provides for tomorrows problems, the entity reference does not. In my world "simple" means do it once, correctly.
annakata
I also disagree. I would be extremely surprised if > was ever removed from the XML spec. CDATA is a sledge hammer that you just don't need for this situation. CDATA also isn't very practical for document-based XML, especially since all modern editors will automatically escape brackets for you.
James Sulak
I made no assertion about > being removed from spec, and you can't qualify the "sledgehammer" argument since we don't *know* the situation in detail, but the OP suggests multiples, ergo CDATA > entity. Further, the editor argument is trivial: it's far more likely this will be handled in code
annakata
I second CDATA.
andyk
thank you! languishing here with +2/-2 when Daok says exactly the same thing at +5! the wonders of SO :)
annakata
+3  A: 

You can try to use Cdata to put all your symbole that doesn't work.

Exampple of something that will work in XML:

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

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

Daok
you'll also have to put in javascript comments so you won't get a syntax error. /* <![CDATA[ */ ... /* ]]> */
nickf
no, no you don't - the *value-of* of the node will not include the CDATA markup - try it
annakata