Datasheet

And for the XML document containing countries, you use a different prefix:
<?xml version=”1.0”?>
<o:WeatherForecastxmlns:o=”http://www.mywebsite.com/nsforcities” date=”2/1/2004”>
<o:city>
<o:name>Frankfurt</o:name>
<o:temperature><o:min>43</o:min><o:max>52</o:max></o:temperature>
</o:city>
<o:city>
<o:name>London</o:name>
<o:temperature><o:min>31</o:min><o:max>45</o:max></o:temperature>
</o:city>
<o:city>
<o:name>Paris</o:name>
<o:temperature><o:min>20</o:min><o:max>74</o:max></o:temperature>
</o:city>
</o:WeatherForecast>
Creating the preceding XML documents using prefixes has actually created separate elements in sepa-
rate documents. This is done by using an attribute and a URL. Also when using a namespace, you don’t
have to assign the prefix to every child element, only the parent node concerned. So with the first XML
document previously listed you can do this:
<?xml version=”1.0”?>
<WeatherForecast xmlns:i=”http://www.mywebsite.com/nsforcities” date=”2/1/2004”>
<city>
<name>Frankfurt</name>
<temperature><min>43</min><max>52</max></temperature>
</city>
<city>
<name>London</name>
<temperature><min>31</min><max>45</max></temperature>
</city>
<city>
<name>Paris</name>
<temperature><min>20</min><max>74</max></temperature>
</city>
</WeatherForecast>
You could also use a namespace for the weather forecast for the countries.
XML in Many Languages
Storing XML documents in a language other than English requires some characters not used in the
English language. These characters are encoded if not stored in Unicode. Notepad allows you to store
text files, in this case XML documents, in Unicode. In Notepad on Win2K, select the Encoding option
under the Save As menu option.
When reloading the XML document in a browser you simply have to alter the XML tag at the beginning
of the script, to indicate that an encoding other than the default is used. Win2K (SP3) Notepad will allow
storage as ANSI (the default), Unicode, Unicode big endian, and UTF-8. To allow the XML parser in a
browser to interpret the contents of an XML document stored as UTF-8 change the XML tag as follows:
<?xml version=”1.0” encoding=”UTF-8”?>
26
Chapter 1
04_791202 ch01.qxp 10/6/06 10:59 AM Page 26