Rahul Vyas
Rahul Vyas

Reputation: 28730

Square brackets in XML?

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

Upvotes: 8

Views: 17486

Answers (3)

Adrian Maire
Adrian Maire

Reputation: 14865

">" does not require to be escaped.

"]" does not require to be escaped.

"]]>" require to be escaped as part of the CDATA element.

Upvotes: 1

RedBlueThing
RedBlueThing

Reputation: 42532

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> 

Upvotes: 3

Kirtan
Kirtan

Reputation: 21695

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>

Upvotes: 16

Related Questions