104 views
XML Example
Certainly! Here’s a simple example of an XML document representing information about two books in a bookstore:
<bookstore>
<book category="fiction">
<title>XQuery 101</title>
<author>John Doe</author>
<price>25.00</price>
</book>
<book category="non-fiction">
<title>XML Fundamentals</title>
<author>Jane Smith</author>
<price>30.00</price>
</book>
</bookstore>
In this XML example:
- The root element is
<bookstore>
, which contains two child elements<book>
. - Each
<book>
element has an attributecategory
to specify whether the book is fiction or non-fiction. - Inside each
<book>
element, there are three child elements:<title>
,<author>
, and<price>
, representing the book’s title, author’s name, and price, respectively.
This XML document follows the hierarchical structure of XML, where each element is nested inside its parent element, forming a tree-like structure. The elements and attributes are used to represent the data in a structured and self-descriptive manner. XML is flexible enough to represent a wide variety of data formats and is commonly used for data interchange, configuration files, web services, and more.