XML Entity for "/"?

Viewed 91017

So I'm writing some XML generating code, and found that the following attribute value was screwing up the XML formatting:

"Jim/Bob"

So I looked into the XML Entities used as escape sequences and every list I saw did not include one for the forward slash. Am I missing something obvious here? Seems like the sort of thing you'd want to escape...

7 Answers

There's no predefined entity reference for it, but you can use a character reference: “/”.

However, you don't need to escape / for inclusion in XML. You might have to include it for inclusion in something else, for example a URI path part. But then you'd have to escape it for that format first; the application that picks up the URI wouldn't have any way to know if you'd encoded it in the XML or not.

I can't see why a value of "Jim/Bob" would need escaping or cause XML any problems at all.

You probably have a constrained attribute, as defined in the XML Schema.

I do not know what you mean by XML formatting.

Related