You are on page 1of 5

Assignment-2

Q1) Design a XML DTD for self-describing weather report having following details data. Describe city,
state, country, Temperature range. Describe high and low temp in F and C.

Ans. [

<!ELEMENT weather_report (date, location, temperature_range)>

<!ELEMENT date (#PCDATA)>

<!ELEMENT location (city, state, country)>

<!ELEMENT city (#PCDATA)>

<!ELEMENT state (#PCDATA)>

<!ELEMENT country (#PCDATA)>

<!ELEMENT temperature_range (high, low)>

<!ELEMENT high (fahrenheit, celsius)>

<!ELEMENT low (fahrenheit, celsius)>

<!ELEMENT fahrenheit (#PCDATA)>

<!ELEMENT celsius (#PCDATA)>

<weatherReports>

<weatherReport>

<date>2024-02-28</date>

<location>

<city>New York City</city>

<state>New York</state>

<country>United States</country>

</location>

<temperature>

<high>

<value unit="Fahrenheit">60</value>

<value unit="Celsius">15.6</value>
</high>

<low>

<value unit="Fahrenheit">45</value>

<value unit="Celsius">7.2</value>

</low>

</temperature>

</weatherReport>

<weatherReport>

<date>2024-02-28</date>

<location>

<city>Los Angeles</city>

<state>California</state>

<country>United States</country>

</location>

<temperature>

<high>

<value unit="Fahrenheit">75</value>

<value unit="Celsius">23.9</value>

</high>

<low>

<value unit="Fahrenheit">55</value>

<value unit="Celsius">12.8</value>

</low>

</temperature>

</weatherReport>

</weatherReports>
Ans 2)

<!ELEMENT library (book+)>

<!ELEMENT book (title, author, genre, year, price)>

<!ELEMENT title (#PCDATA)>

<!ELEMENT author (#PCDATA)>

<!ELEMENT genre (#PCDATA)>

<!ELEMENT year (#PCDATA)>

<!ELEMENT price (#PCDATA)>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE library SYSTEM "books.dtd">

<library>

<book>

<title>The Great Gatsby</title>

<author>F. Scott Fitzgerald</author>

<genre>Fiction</genre>

<year>1925</year>

<price>10.99</price>

</book>

<book>

<title>To Kill a Mockingbird</title>

<author>Harper Lee</author>

<genre>Fiction</genre>

<year>1960</year>

<price>12.50</price>

</book>

<book>
<title>1984</title>

<author>George Orwell</author>

<genre>Dystopian Fiction</genre>

<year>1949</year>

<price>9.99</price>

</book>

</library>

Ans 3)

XML (Extensible Markup Language) and HTML (Hypertext Markup Language) are both markup
languages used for structuring and organizing data, but they serve different purposes and have
different features.

XML (Extensible Markup Language):

XML is a markup language designed to store and transport data.

It is a text-based format that consists of customizable tags used to define the structure and meaning
of data.

XML is extensible, meaning that you can define your own tags to represent the data in a way that
makes sense for your application or domain.

It is commonly used for data interchange between different systems and platforms, as it provides a
standardized format for representing structured data.

XML is often used in configurations, web services, data storage, and other applications where
structured data needs to be exchanged between different systems.

Key Differences:

Purpose: XML is designed for data interchange and storage, while HTML is designed for displaying
content in web browsers.

Customizability: XML allows for the creation of custom tags to represent any kind of structured data,
whereas HTML has a fixed set of tags predefined for creating web pages.
Focus: XML focuses on the structure and meaning of data, whereas HTML focuses on the
presentation of content.

Rendering: XML is not rendered by web browsers; it is processed by applications or systems that
understand its structure and semantics. HTML is rendered directly by web browsers to display
content to users.

Usage: XML is used for data interchange, configuration files, web services, etc., while HTML is used
for creating web pages and web applications.

In summary, XML is a versatile markup language used for representing structured data, while HTML
is specifically designed for creating web pages and displaying content in web browsers.

You might also like