XML Attributes
In HTML we can have <table width="100">. The "width"
attribute provides additional information about the <table> element. To
provide additional information about elements, XML elements can also have attributes
in the start tag, just like HTML. For example, <category name="GPS">
Please note, in an XML file, an attribute value must be quoted with either
single or double quotes.
Take a look at these examples:
<customer gender="male">
<firstname>John</firstname>
<lastname>Smith</lastname>
</customer>
<customer>
<gender>male</gender>
<firstname>John</firstname>
<lastname>Smith</lastname>
</customer>
In the first example gender is an attribute. In the last, gender is an element.
Both examples contain the same information.
|