delta one handle kitchen faucets

Home XML Attributes
« Home »
Sep 24th, 2012 Comments: 0

XML Attributes

Share this


An attribute is placed within the opening tag of the element.  The attributes in XML are very similar to those in HTML except those in XML are required to have values.  Examples of both incorrect and correct ways to insert attributes are shown in the examples below.


<student enrolled>





Example: CORRECT

<student enrolled=”true”>





Both double quote (“) and single quote (‘) are valid in XML documents and it is up to the creator to determine which ones to use.  There are a few instances where one type of quotation may make more sense than the other.  For example, if the attribute value has its own set of double quotes, it may make more sense to use a single quote to close the attribute.

When using attributes, there are a few drawbacks that you should keep in mind. Attributes cannot do the following:

  • Contain multiple values like elements
  • Contain tree structures like elements
  • Easily be expanded for future changes

In addition to these drawbacks, attributes can sometimes be difficult to maintain and read.  It is a good practice to use elements to present data and attributes to present data that is not relevant to data.  Also, if using metadata, it can be stored as attributes rather than elements.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>