Page 176 - Data Science class 11
P. 176

4.8 StruCture Of an XML DOCuMent

        XML Structure is Extensible.
        Most XML applications will work as expected even if new data is added (or removed).

        Imagine an application designed to display the original version of note.xml (<to> <from> <heading> <body>).
        Then imagine a newer version of note.xml with added <date> and <hour> elements, and a removed <heading>.


                          <note>
                               <date>04.04.2022</date>
                               <hour>10.00</hour>
                               <to>Harry</to>
                               <from>Samuel</from>
                               <body>Let's catch-up this weekend!</body>
                          </note>


        Let us consider another example of an XML document depicting its parts:

        <?xml version = "1.0"?>
                                                                               Document Prolog
        <contact-info>
           <name>Abhishek Kashyap</name>
           <company> Kashyap Consultants</company>
                                                                               Document Elements
           <phone>(011) 417-0038</phone>
        </contact-info>
        4.8.1 Document prolog Section

        Document Prolog comes at the top of the document, before the root element. This section contains:
           • XML declaration
           • Document type declaration
        XML declaration contains details that prepare an XML processor to parse the XML document. It is optional, but when
        used, it must appear in the first line of the XML document.


        4.8.2 Document elements Section
        Document Elements are the building blocks of XML. These divide the document into a hierarchy of sections, each
        serving a specific purpose. You can separate a document into multiple sections so that they can be rendered differently,
        or used by a search engine. The elements can be containers, with a combination of text and other elements.

        XML Tags
        Let us learn about the most important part of XML—the XML tags. XML tags form the foundation of XML. They define
        the scope of an element in XML. They can also be used to insert comments, declare settings required for parsing the
        environment, and to insert special instructions.

        We can broadly categorize XML tags as follows:

        Start Tag
        The beginning of every non-empty XML element is marked by a start-tag. Following is an example of start-tag:

        <address>




          174   Touchpad Data Science-XI
   171   172   173   174   175   176   177   178   179   180   181