Elements vs. Attributes in XML
Data can be stored in child elements or in attributes.
Take a look at these examples:
< person sex="female" >
< firstname>Anna
< lastname>Smith
< /person >
< person >
< sex >female< /sex >
< firstname >Anna< /firstname >
< lastname >Smith< /lastname >
< /person >
• In the first example sex is an attribute. In the last, sex is a child element. Both examples provide the same information.
• There are no rules about when to use attributes, and when to use child elements.. Use child elements if the information feels like data.
XML Attributes
XML elements can have attributes.
• From HTML you will remember this:
. The SRC attribute provides additional information about the IMG element.
• In HTML (and in XML) attributes provide additional information about elements:

Leave a comment