XML Attributes

The attributes used to add additional information to the elements.

The value of an attribute must be enclosed in double quotes or single quotes.

XML Syntax Attributes:

<tag attribute="value of attribute"> value of the tag </tag>

Example XML attributes:

<message> element has an attribute "type" with value "mail".

    <message type="mail">         <from>James</from>         <to>Peter</to>         <title>Meeting</title>         <text>Remember our meeting</text>     </message>

We can use single quotes when the attribute value has a double quote inside, for example:

<message type='john "secret" mail'> value of the message </message>
Recommendation: Convert the attributes to elements because they are more flexible and manageable. For example, the above example would read:

    <message>         <type>mail</type>         <from>James</from>         <to>Peter</to>         <title>Meeting</title>         <text>Remember our meeting</text>     </message>