Learn XML - XML tutorial - Attributes - XML examples - XML programs
Xml attribute Example
Attribute Vs Element
- Metadata should be stored as attribute and data should be stored as element.
Attribute vs Sub-element or Elements
- Attributes are part of markup, while sub elements are part of the basic document contents.
In the below code bookType is an attribute
In the below code bookType is an element
Learn XML - XML tutorial - XML Attributes - XML examples - XML programs
Read AlsoAccept Attribute in HTML
XML Attributes Rules
- An attribute name must be appear once in the same start-tag or empty-element tag.
- The value of the attributes within the quotation mark.
- They used either single or double quotes.
Learn XML - XML tutorial - Attributes With Quotes - XML examples - XML programs
- Attributes must contain a value. Some HTML coders does provide the attribute name without a value or it will equal true. This is not allowed in XML.
- The values must not contain direct or indirect entity references to external entities.
- Using an Attribute-List Declaration , an attribute must be declared in the Document Type Definition (DTD).
Learn XML - XML tutorial - Attributes Value - XML examples - XML programs
XML Tree Structure
Learn XML - XML tutorial - XML Tree Structure - XML examples - XML programs
XML Attributes Drawbacks:
- Attributes doesn’t have multiple values but child elements can have multiple values.
- Attributes cannot contain tree structure but child element can.
- Attributes are not easily expandable. If you want to change in attribute's vales in future, it may be complicated.
- Attributes cannot describe structure but child elements can.
- Attributes are more difficult to be manipulated by program code.
- Attributes values are not easy to test against a DTD, which is used to define the legal elements of an XML document.
How XML is Presented ?
Learn XML - XML tutorial - How XML is Presented - XML examples - XML programs