XML Introduction

XML refers to Extensible Markup Language. It is used to store and to transport data.

XML SYNTAX DOESN’T HAVE PREDEFINED TAGS

The XML language do not have any predefined tags.

The tags in the example below(student, course, etc) are not defined in any XML standard. These tags are “Created” by the author of the XML document.

HTML works with predefined tags like  <h1>, <p>, <table>, etc.

With XML, the developer must define both the document structure and  the tags. And each tag must have its starting and ending tags.

EXAMPLE 1

<college>
     <course1>
           <subject1></subject1>
           <subject2></subject2>
     </course1>
     <course2>
          <subject3></subject3>
     </course2>
</college>

The above example explain how we could arrange the element tags to maintain the data through XML.

In the above example, It explain that a college may have multiple courses and each course have their subjects.

This is how we write XML document.
The Elements in XML document may contain other elements or data or nothing. 

EXAMPLE 2

<root>
  <child1>
    <subchild>syntax definition</subchild>
  </child1>

  <child2>
  </child2>
</root>

In the above example first tag also refer as element named as root contains two sub elements named child1 and child2.

And child1 contain a data value which is “syntax definition” where as element named as child2 is empty

 

PROLOG

A Prolog defines the XML version and the character encoding. However it is completely optional but if used it must be place at top of document.

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

 

Facebooktwittergoogle_pluspinterestlinkedinmail