Web Designing 2 — Study Notes

Unit 01

XML — eXtensible Markup Language

4 Questions 6 Marks Each Web Designing 2
01
6 Marks Question

Characteristics and Uses of XML

Definition

XML (eXtensible Markup Language) is a markup language designed to store and transport data in a structured and self-descriptive way.

Characteristics of XML

Self-descriptive
XML tags describe the data clearly (e.g., <name>Rahul</name>), so the meaning of data is easy to understand.
Extensible
Users can create their own custom tags according to their needs, making XML highly flexible.
Platform and Language Independent
XML is plain text and can be used on any operating system and with any programming language.
Hierarchical Structure
XML data is organized in a tree structure with a single root element and nested child elements.
Strict Syntax
XML follows strict rules (proper closing tags, correct nesting), which ensures data accuracy and consistency.

Uses of XML

Data Storage and Transport
XML stores data in structured form and is widely used to exchange data between systems.
Platform-independent Data Exchange
Used to transfer data between different applications and platforms easily.
Web Services (SOAP)
XML is commonly used in web services and APIs for communication between client and server.
Configuration Files
Many applications use XML files to store configuration settings.
Data Validation
XML documents can be validated using DTD or XSD to ensure correct structure and data types.
Conclusion XML is a flexible, self-descriptive, and platform-independent language widely used for storing, validating, and exchanging structured data.
02
6 Marks Question

XML Syntax

Definition

XML syntax refers to the set of rules that must be followed while writing a well-formed XML document. These rules ensure that XML data is correctly structured and readable by both humans and machines.

Basic Rules of XML Syntax

01 XML Declaration (Optional but First)

If used, it must be the very first line in the document. The version attribute is mandatory if the declaration is present.

<?xml version="1.0" encoding="UTF-8"?>
02 Single Root Element

Every XML document must have exactly one root element that contains all other elements.

03 Proper Opening and Closing Tags

Every element must have a closing tag. Unlike HTML, closing tags are mandatory.

<name>Rahul</name>
04 Proper Nesting of Elements

Tags must be correctly nested and must not overlap.

Correct<a><b></b></a> Wrong<a><b></a></b>
05 Case Sensitivity

XML is case-sensitive. <Name> and <name> are treated as different elements.

06 Attribute Values Must Be Quoted

Attribute values must be enclosed in single or double quotes.

<student id="101">
07 Elements Must Be Properly Named

Element names should start with a letter or underscore and must not contain spaces.

Example of a Well-Formed XML Document

<?xml version="1.0" encoding="UTF-8"?>
<contact_info>
  <name>Rajesh</name>
  <company>TCS</company>
  <phone>9333332354</phone>
</contact_info>

This example contains markup (tags) and text data inside the elements.

Conclusion XML syntax rules ensure that documents are well-structured, error-free, and easily processed by applications.
03
6 Marks Question

How to Declare XML and Rules of XML Declaration

XML Declaration

XML declaration is the optional first line of an XML document that specifies the XML version and encoding used. It provides information about the document to the parser.

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

Attributes of XML Declaration

  • version Specifies the XML version. Example: version="1.0" Required
  • encoding Specifies character encoding such as UTF-8 or UTF-16. Optional
  • standalone yes — document does not depend on external DTD. no — document depends on external DTD. Optional

Rules of XML Declaration

01 Must Be the First Line

If present, it must appear at the very beginning of the XML file with no spaces or characters before it.

02 Must Begin with <?xml in Lowercase

The keyword xml must be written in lowercase. XML is case-sensitive.

03 Correct Attribute Order

Attributes must appear in this specific order:

version encoding standalone
04 Version Attribute is Required

If the declaration is used, the version attribute must be included.

05 No Closing Tag

XML declaration is self-contained and does not have a closing tag.

06 Attribute Names Must Be Lowercase

Names like version, encoding, standalone must all be in lowercase.

07 Quotes Required

Attribute values must be enclosed in single or double quotes.

Example

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<students>
  <student>Rahul</student>
</students>
Conclusion XML declaration gives essential information about the XML document and must follow strict syntax rules to ensure proper parsing.
04
6 Marks Question

Difference Between XML and HTML

XML and HTML are both markup languages, but they serve different purposes. XML is mainly used to store and transport data, while HTML is used to display data on web pages.

Simple Explanation: XML tells what the data is. HTML tells how the data looks.

Key Differences Between XML and HTML

BasisXMLHTML
Full FormeXtensible Markup LanguageHyperText Markup Language
PurposeStores and transports dataDisplays data / web pages
TagsUser-defined (custom tags)Predefined tags
Case SensitivityCase-sensitiveNot case-sensitive
Error HandlingStrict (errors not allowed)Lenient (ignores minor errors)
FocusData structure and meaningPresentation and layout
Closing TagsMandatorySome optional
ValidationSupports DTD/XSD validationNo data validation
ExtensibilityHighly extensibleNot extensible

Example Comparison

XML — Describes Meaning
<student>
  <name>Rahul</name>
  <course>XML</course>
</student>
HTML — Controls Display
<p>Rahul</p>
<p>XML</p>

XML describes the meaning of data, while HTML only controls its display.

Conclusion XML is used for data storage and exchange with custom tags, whereas HTML is used for designing and displaying web pages using predefined tags.