What Is Structure of XML Data and XML Document Schema?


Scott Campbell

XML, short for eXtensible Markup Language, is a widely used format for storing and transporting structured data. It provides a way to describe data in a hierarchical manner, making it easier to organize and exchange information between different systems.

The structure of XML data is defined by its document schema. A schema is a set of rules that determines the structure, content, and data types allowed in an XML document. It acts as a blueprint for creating valid XML documents that conform to a specific format.

Structure of XML Data:
At the core of XML data is the concept of elements. Elements are the building blocks of an XML document and represent different entities or pieces of information. Each element has a start tag, an end tag, and can contain other elements or text.



  • Title:

    Harry Potter and the Philosopher’s Stone

  • Author:

    J.K. Rowling

  • Year:



In this example, the <book> element is the root element, enclosing all other elements within it. The <title>, <author>, and <year> elements are child elements of the <book> element.

The Document Schema:
The document schema defines the allowable structure for an XML document. It can be represented using various schema languages such as Document Type Definitions (DTD), XML Schema Definition (XSD), or Relax NG.

A document schema specifies the elements, attributes, data types, and relationships between elements. It ensures that XML documents adhere to a predefined structure and can be validated against the schema.


XML Schema:

<xs:element name="book">
      <xs:element name="title" type="xs:string"/>
      <xs:element name="author" type="xs:string"/>