In XML, some symbols are used as the markup symbols of XML. In some cases, attribute values must carry these special symbols. The following describes how to process common special symbols.
Example 1: Use double quotation marks.
Double quotation marks are the start and end symbols of XML Attribute values. Therefore, you cannot directly use "" In values. There are two processing methods.
A: The attribute value does not contain '(single quotes). You can use' as the start and end symbol of the attribute value.
< Add Key = " IPhone " Value = "Apple" />... The property value is ("apple ").
solution: Add key = " iPhone " value =' " apple "' />
B: The attribute values include '(single quotation marks) and double quotation marks. For example... The property value is ("'apple ").
< Add Key = " IPhone " Value = "& Quot;& Apos;Apple& Quot;" />
The following table lists five built-in entities for the characters used by the XML tag.
Entity |
Entity reference |
Description |
Lt |
& Lt; |
<(Yu no) |
GT |
& Gt; |
> (Greater than the number) |
Amp |
& Amp; |
& ("And) |
APOs |
& Apos; |
'(Apostrophes or single quotes) |
Quot |
& Quot; |
"(Double quotation marks) |
If the character may cause the XML analyzer to incorrectly interpret the document structure, use an object instead of a character.& Apos;And& Quot;Object references are most commonly used in attribute values.