From the following trials
<tag attr="\"">
<tag attr="<![CDATA["]]>">
<tag attr='"'>
Only the last one works for an XML parser that I'm using here. Is there an alternative?
您可以使用"
From the XML specification :
To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "'", and the double-quote character (") as """.
A double quote character ( "
) can be escaped as "
, but here's the rest of the story...
In XML attributes delimited by double quotes:
<EscapeNeeded name="Pete "Maverick" Mitchell"/>
In XML textual content:
<NoEscapeNeeded>He said, "Don't quote me."</NoEscapeNeeded>
In XML attributes delimited by single quotes ( '
):
<NoEscapeNeeded name='Pete "Maverick" Mitchell'/>
Similarly, ( '
) require no escaping if ( "
) are used for the attribute value delimiters:
<NoEscapeNeeded name="Pete 'Maverick' Mitchell"/>
Coder's Toolbox站点上的字符串转换页面可以方便地对少量 HTML 或 XML 代码进行编码,以便将其作为值包含在 XML 元素中。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.