0% found this document useful (0 votes)
6 views

XML

XML

Uploaded by

ayaankim007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

XML

XML

Uploaded by

ayaankim007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

XML (Extensible Markup Language)

Introduction

XML (Extensible Markup Language) is a markup language designed to store and transport
data in a format that is both human-readable and machine-readable. Developed by the
World Wide Web Consortium (W3C), XML is widely used in web technologies, data
exchange, and configuration files. Unlike HTML, which focuses on the presentation of data,
XML emphasizes the structure and storage of data.

Features of XML

1. Simplicity: XML uses plain text, making it easy to read and write.
2. Platform Independence: XML is hardware and software-independent, allowing
seamless data exchange across systems.
3. Self-descriptive Tags: Tags in XML describe the data they contain, making the
structure self-explanatory.
4. Extensibility: XML allows users to define their custom tags to suit specific needs.
5. Data Validation: XML can validate data using Document Type Definition (DTD) or
XML Schema.
6. Hierarchical Structure: XML data is organized hierarchically, which is ideal for
representing complex relationships.
7. Unicode Support: XML supports Unicode, enabling the representation of data in
various languages.

Naming Rules in XML

1. Names can contain letters, numbers, underscores (_), hyphens (-), and periods (.).
2. Names must start with a letter or an underscore; they cannot start with a number or
punctuation character.
3. Names cannot contain spaces.
4. XML names are case-sensitive.
5. Reserved words like "xml" (in any case combination) cannot be used as element
names.

Uses of XML

1. Data Storage and Transport: XML is commonly used to store and exchange data
between systems.
2. Web Services: Used in SOAP and REST APIs for data communication.
3. Configuration Files: XML is used to define settings in applications, such as
.config files.
4. Document Representation: Formats like DOCX and ODT are based on XML.
5. Database Interactions: XML is used to represent data in databases and query
results.
6. RSS Feeds: For syndicating website content.

Building Blocks of an XML Document

1. Prolog: Contains the XML declaration and optional processing instructions. Example:
<?xml version="1.0" encoding="UTF-8"?>
2. Elements: The core building blocks, represented by start and end tags. Example:
<name>Disha</name>
3. Attributes: Provide additional information about elements. Example: <student
id="123">Disha</student>
4. Text: The data within the elements. Example: Disha in <name>Disha</name>.
5. Comments: Provide explanatory notes. Example: <!-- This is a comment
-->
6. CDATA Sections: Used for text that should not be parsed by the XML parser.
Example: <![CDATA[<html>Text</html>]]>

Difference Between HTML and XML


Feature HTML XML

Purpose Displaying data on web Storing and transporting data


pages

Tags Predefined User-defined

Syntax Not strict Strict

Case Not case-sensitive Case-sensitive


Sensitivity

Data Validation Not validated Can be validated using


DTD/Schema

Self-descriptiv No Yes
e

XML Parser
An XML Parser is a tool that reads XML documents and provides access to their structure
and data.

1. Types of XML Parsers:


○ DOM Parser: Loads the entire XML document into memory and represents it
as a tree structure. Suitable for small XML files.
○ SAX Parser: Parses XML documents sequentially and does not load the
entire file into memory. Suitable for large XML files.
2. Functions of XML Parsers:
○ Validate the XML structure.
○ Extract and manipulate XML data.
○ Ensure compliance with DTD or Schema.

DTD (Document Type Definition)

DTD is used to define the structure, elements, and attributes of an XML document. It
ensures that the XML document adheres to a specific format.

Example of DTD:

Using XML with HTML and CSS


● Embedding XML in HTML: XML data can be embedded into an HTML document
using JavaScript.

● Styling XML with CSS: XML documents can be styled using CSS by associating an
external stylesheet.

CSS File (style.css):

You might also like