Company name for an attribute
- Text to encode
- Smith & Sons "Ltd"
- Quote marks
- Encode quotes
- Write non-ASCII as &#x…; references
- No
Result Encoded XML text: Smith & Sons "Ltd"
Characters replaced: 3
Input characters: 18
Output characters: 32
- Each & becomes & first in the same pass, so existing entities are encoded again rather than skipped.
- Quotes are encoded as " and ', safe inside attribute values.
- Non-ASCII characters are kept as typed (valid in a UTF-8 document).
The ampersand and both double quotes are replaced, so the name can sit inside name="…" without ending the attribute early.