现实生活中的 XML
现实生活中的 XML
一个现实生活中的例子,向您展示 XML 如何携带数据。
实例: XML 新闻
XMLNews 是用于交换新闻和其他信息的规范。
对新闻的供求双方来说,通过使用这种标准,可以使各种类型的新闻信息通过不同软硬件以及编程语言进行的制作、接收和存档更加容易。
一个 XMLNews 文档实例:
<?xml version="1.0" encoding="ISO-8859-1"?> <nitf> <head> <title>Colombia Earthquake</title> </head> <body> <headline> <hl1>143 Dead in Colombia Earthquake</hl1> </headline> <byline> <bytag>By Jared Kotler, Associated Press Writer</bytag> </byline> <dateline> <location>Bogota, Colombia</location> <date>Monday January 25 1999 7:28 ET</date> </dateline> </body> </nitf>
实例:XML Weather Service
国家气象服务案例,来自 NOAA (National Oceanic and Atmospheric Administration):
<?xml version="1.0" encoding="ISO-8859-1" ?> <current-observation> <credit>NOAA's National Weather Service</credit> <credit-URL>http://weather.gov/</credit-URL> <image> <url>http://weather.gov/images/xml-logo.gif</url> <title>NOAA's National Weather Service</title> <link>http://weather.gov</link> </image> <location>New York/John F. Kennedy Intl Airport, NY</location> <station-id>KJFK</station-id> <latitude>40.66</latitude> <longitude>-73.78</longitude> <observation-time-rfc822> Mon, 11 Feb 2008 06:51:00 -0500 EST </observation-time-rfc822> <weather>A Few Clouds</weather> <temp-f>11</temp-f> <temp-c>-12</temp-c> <relative-humidity>36</relative-humidity> <wind-dir>West</wind-dir> <wind-degrees>280</wind-degrees> <wind-mph>18.4</wind-mph> <wind-gust-mph>29</wind-gust-mph> <pressure-mb>1023.6</pressure-mb> <pressure-in>30.23</pressure-in> <dewpoint-f>-11</dewpoint-f> <dewpoint-c>-24</dewpoint-c> <windchill-f>-7</windchill-f> <windchill-c>-22</windchill-c> <visibility-mi>10.00</visibility-mi> <icon-url-base> http://weather.gov/weather/images/fcicons/ </icon-url-base> <icon-url-name>nfew.jpg</icon-url-name> <two-day-history-url> http://www.weather.gov/data/obhistory/KJFK.html </two-day-history-url> <disclaimer-url> http://weather.gov/disclaimer.html </disclaimer-url> <copyright-url> http://weather.gov/disclaimer.html </copyright-url> </current-observation>