Along with its use in many aspects of web development, XML is also used to separate data from presentation.
Separating Data from Presentation:
The information about how to be displayed is not carried by XML. With a full separation between data and presentation, the XML data can be used in many different presentation scenarios.
XML is Often a Complement to HTML:
The HTML is generally used to format and display the same data, while, XML is often used in HTML applications to store or transport data.
Separating Data from HTML:
To not edit the HTML file, when the data changes while displaying data in HTML, we can use XML to store the data in separate XML files. We can read an XML file and update the data content of an HTML page, with just a few lines of JavaScript code.
Example: Books.xml:
ABC Unknown 2020 100.00 XQuery Book Author 1 Author 2 Author 3 Author 4 2004 350.00
Output: XML Tree:
Transaction Data:
To describe day-to-day data transactions, in different industries, thousands of XML formats exist.
- Stocks and Shares
- Financial transactions
- Medical data
- Mathematical data
- Scientific measurements
- News information
- Weather services
XML News:
For exchanging news and other information, XMLNews is used as a specification which makes it easier for both news producers and news consumers to produce, receive, and archive any kind of news information across different hardware, software, and programming languages.
Example:
CoronaVirus Millions Dead in World By Editor, Example Press India Tuesday June 2 2020 8:28 IST
Output: XML Tree:
XML Weather Service:
In the below example, we are demonstrating an XML national weather service from NOAA (National Oceanic and Atmospheric Administration):
Example:
NOAA's National Weather Service http://weather.gov/ http://weather.gov/images/xml_logo.gif NOAA's National Weather Service http://weather.govNew York/John F. Kennedy Intl Airport, NY KJFK 40.66 -73.78 Mon, 11 Feb 2008 06:51:00 -0500 EST A Few Clouds 11 -12 36 West 280 18.4 29 1023.6 30.23 -11 -24 -7 -22 10.00 http://weather.gov/weather/images/fcicons/ nfew.jpg http://weather.gov/disclaimer.html http://weather.gov/disclaimer.html
Output: XML Tree: