[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
How_To_XML_Create_Attributes_XML_Document
XML attributes are added to the XML element's starting tag and their value must be enclosed in single or double quotes like this:
<book ISBN="0321173481"> or <book ISBN='0321173481'>
The ISBN is the attribute's name and '0321173481' is the attribute's value.
The two samples are equivalent in terms of information.
You can use either way though attributes may not be as easy to handle as elements. Use attributes when the attribute does not strictly belong to the element but carries some data about it. IDs are typically attributes.
XML FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
How_To_XML_Create_Attributes_XML_Document
How to create attributes in an XML document?
XML attributes can be thought of as HTML attributes in that they are used to provide more information about an element. In the case of XML, you can define your own elements, attributes and their values.XML attributes are added to the XML element's starting tag and their value must be enclosed in single or double quotes like this:
<book ISBN="0321173481"> or <book ISBN='0321173481'>
The ISBN is the attribute's name and '0321173481' is the attribute's value.
The two samples are equivalent in terms of information.
<?xml version="1.0"?>
<books>
<book>
<ISBN>0321173481</ISBN>
<title>OpenGL Programming Guide Fourth Edition</title>
</book>
</books><?xml version="1.0"?>
<books>
<book ISBN="0321173481">
<title>OpenGL Programming Guide Fourth Edition</title>
</book>
</books>You can use either way though attributes may not be as easy to handle as elements. Use attributes when the attribute does not strictly belong to the element but carries some data about it. IDs are typically attributes.
XML FAQ
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
