16. XML Attribute Quoting

Attribute values are required to be quoted. It is illegal to omit quotation marks around attribute values. Either single or double quotes can be used.

Example 16.1 Improper Attribute Value
	
<childelement1 attribute1=An attribute value.>An element value.</childelement1>
	
Example 16.2 Proper Attribute Value
<childelement1 attribute1="An attribute value.">An element value.</childelement1>
	

If the attribute value itself contains double quotes it is necessary to use single quotes. If the attribute value itself contains single quotes it is necessary to use double quotes.

Example 16.3 Double Quotes Attribute Value Usage
<childelement1 attribute1='An "attribute" value.'>An element value.</childelement1>
	
Example 16.4 Single Quotes Attribute Value Usage
<childelement1 attribute1="An 'attribute' value.">An element value.</childelement1>