What is Xml ?

XML stands for eXtensible Markup Language. It’s a simple and flexible text-based format used to store and transport data. In easy language, you can think of XML as a way to organize information in a structured manner. In XML, data is enclosed in tags, which are like labels or markers that define the beginning and end of elements. These elements can contain text, other elements, or attributes that provide additional information about the data.

How can XML be Used ?

  1. Create an XML Document :- Start with a root element, like , to wrap around all your information. Inside the root, add other elements to represent different pieces of data.
  2. Use Tags for Data:– Each piece of information is enclosed in a tag. For example, and are tags. Open and close each tag to define the beginning and end of the data.
  3. Nesting Elements:- You can nest elements inside each other to show relationships. For instance, elements are nested inside the element.

4. Add Attributes:- If an element needs additional details, use attributes. These go inside the opening tag.

5. Save as Xml:- Once you’ve created your XML, save it with a .xml file extension (e.g., mydata.xml).

6. Read Xml : – Other programs or systems can read your XML to understand the data structure.
For example, a program might read the XML to know there are people with names and ages.

Explain Code :-

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

  <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>

  <book category="children">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
  </book>

  <book category="web">
    <title lang="en">XQuery Kick Start</title>
    <author>James McGovern</author>
    <author>Per Bothner</author>
    <author>Kurt Cagle</author>
    <author>James Linn</author>
    <author>Vaidyanathan Nagarajan</author>
    <year>2003</year>
    <price>49.99</price>
  </book>

  <book category="web" cover="paperback">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
    <year>2003</year>
    <price>39.95</price>
  </book>

</bookstore>

Leave a Comment