JavaScript Editor Free JavaScript Editor     JavaScript Debugger 




Main Page

Previous Page
Next Page

6.2. Attributes

Attributes are a name-value pair that is contained in an element's start tag. The name portion of an attribute is separated from the value by an equals sign, and the value is enclosed in either single or double quotes. Elements can have multiple attributes, separated from one another by whitespace, usually one or more spaces. It is not unusual for XML documents to use a combination of container elements and attributes. Listing 6-5 shows what the XML document in Listing 6-4 would look like using attributes.

Listing 6-5. An XML Document with Attributes

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<library>
      <book series="The Lord of the Rings" title="The Fellowship of the
Ring" author="J.R.R. Tolkien"/>
      <book series="The Lord of the Rings" title="The Two Towers"
author="J.R.R. Tolkien"/>
      <book series="The Lord of the Rings" title="The Return of the King"
author="J.R.R. Tolkien"/>
</library>

Before proceeding any further, I want to cover the three rules for the naming of elements and attributes; these rules are only slightly more complex than the rules for the addressing of cats. The first rule is that only alphanumeric (az, 09) characters, the underscore (_), the hyphen/dash (-), and the colon (:) are permissible in names. The second rule is that names can begin only with an alpha, underscore, or hyphen character. The third and final rule is that names are case sensitive, so Mistoffelees is a different animal than MISTOFFELEES, and mistoffelees is yet another animal. Think of these rules as a practical guide, and you won't have any problems with names.


Previous Page
Next Page

Check myassignmenthelp.com reviews to learn the most dependable reviews by students


JavaScript Editor Free JavaScript Editor     JavaScript Debugger


©