Datasheet
2. All you do is add an attribute name-value pair to each opening <country> tag:
<country currency=”Kwacha”>Zambia</country>
3. The final XML document looks something like this:
<?xml version=”1.0”?>
<regions>
<region>Africa</region>
<country currency=”Kwacha”>Zambia</country>
<country currency=”Zimbabwe Dollars”>Zimbabwe</country>
<region>Asia</region>
<country>Burma</country>
<region>Australasia</region>
<country currency=”Dollars”>Australia</country>
<region>Caribbean</region>
<country currency=”Dollars”>Bahamas</country>
<country currency=”Dollars”>Barbados</country>
</regions>
4. Figure 1-9 shows the result when executed in a browser.
Figure 1-9: Adding attributes to elements in an XML document
How It Works
All you did was to edit an XML document containing the XML tag, a single root node, and various
regions of the world that contained some of their respective countries. You then proceeded to add cur-
rency attributes into some of the countries.
23
What Is XML?
04_791202 ch01.qxp 10/6/06 10:59 AM Page 23