Reputation: 16401
I want to have a string element with the following contents:
<UmlMessage>"@MainApp -> ControlThread : <font color=red><b>NET_SET_REQ</b>"</UmlMessage>
So the element UmlMessage value will be: "@MainApp -> ControlThread : <font color=red><b>NET_SET_REQ</b>"
I added the quotes, but that did not help. I get a strange error:
XMLSyntaxError: AttValue: " or ' expected, line 25, column 54
I assume it is to do with having XML-like tags in the value. But I want what is between the tags to be parsed as a string literal... is that possible?
Upvotes: 2
Views: 5709
Reputation: 158200
Wrap the string content in a CDATA
element if it contains "problematic" characters:
<UmlMessage><![CDATA["@MainApp -> ControlThread : <font color=red><b>NET_SET_REQ</b>"]]></UmlMessage>
Upvotes: 2
Reputation: 111726
Option 1, assuming you don't really need the double quotes around the whole message, and you don't mind the contents of UmlMessage
being parsed as XML:
<UmlMessage>@MainApp -> ControlThread : <font color="red"><b>NET_SET_REQ</b></font></UmlMessage>
Option 2, as above but with double quotes around message:
<UmlMessage>"@MainApp -> ControlThread : <font color='red'><b>NET_SET_REQ</b></font>"</UmlMessage>
Option 3, if you don't want the contents of UmlMessage
to be parsed as XML, regardless of whether you require the surrounding quotes:
<UmlMessage><![CDATA["@MainApp -> ControlThread : <font color=red><b>NET_SET_REQ</b></font>"]]></UmlMessage>
BTW, even though browsers will tolerate missing delimiters around attribute values (color=red
), I'd still recommend using them so that your markup is well-formed XML. Similarly, I especially recommend explicitly closing the font
element and have done so for you in the above examples.
Upvotes: 2