views:

601

answers:

3

In an XML document, how do I treat square brackets (] or [) ?

+2  A: 

There is probably a better solution. But this works:

]

as in:

<blah value="&#x005D;"></blah>

then again, so does (see Kirtan's answer):

<blah value="]"></blah>
Cannonade
+9  A: 

Square brackets do not need a specific notation in XML but they have a special meaning when used in XPath expressions for XSL transformations.

<root>
  <el attrib="[">[</el>
</root>
Kirtan
+1 from me for the more informed answer :P.
Cannonade
A: 

CDATA

JP Alioto
Absolutely zero reason to use CDATA.
bortzmeyer