user251149
user251149

Reputation: 11

Special Character in XML Attribute Value

I want to put a colon in an attribute value that is used to display the title of a chart on my webpage.

I have something like:

<chart displayname="This is the chart name"  resource = "blah blah blah">

I want the display name to be something like "This: is the chart name"

How can I accomplish this?

If it helps here are the HTML codes of the characters I want to use: &#45; and &#58;

Upvotes: 1

Views: 2527

Answers (2)

Anthony
Anthony

Reputation: 37045

If you want to keep your attributes alphanumeric, use the UTF notation instead of the colon:

  displayname="This&#58;My Chart"

Obviously the semicolon and spaces are not alphanumeric, but the above will achieve what I think you are going for.

Upvotes: 0

Ned Batchelder
Ned Batchelder

Reputation: 375474

Colon is not a special character. Just put it in there, it will work.

Upvotes: 3

Related Questions