What is XML (eXtensible Markup Language)

What is XML (eXtensible Markup Language)

We have earlier discussed HTML, which is a W3C standard markup language. HTML tags are predefined, and we can add custom tags in HTML. But what, if you want your whole markup language to be custom one such that it is capable of sending, receiving, storing and displaying data. In that case, we go for XML.
In reality, XML does not do anything by itself. It is just an information wrapped within tags. XML tags are not predefined and, therefore, needs someone to define meaning of its each tag.

Points to remember:

  • XML documents are just like HTML and thus have element trees with a root element.
    XML Syntax
    This can be understood with an example of table.
    XML Example
  • All XML must have a closing tag (as shown in above examples)
  • XML tags are case sensitive (Column and column are different tags in XML)
  • XML elements must be properly nested (It means, you cannot have </columns> tag before </Column> tag)
  • XML attribute values must always be quoted (In above example, “Column1” is an attribute value and is quoted)
  • You cannot insert some characters in XML. To use these characters, you will have to use their alternate names. Following are the characters with their alternatives:
Character (Description) Alternative to be used in XML
< (Less than) &lt;
> (Greater than) &gt;
& (Ampersand) &amp;
‘ (Apostrophe) &apos;
“ (Quotation mark) &quot;

  • The syntax for adding comments in XML is similar to that of HTML
    (<!– This is a comment –>)
  • White spaces in XML are preserved and not ignored (The text is displayed with the white spaces added initially)
  • XML uses prefix to avoid name conflict
    If you have multiple XML libraries, how will you differentiate among the origin of that tag. To solve this issue, we use a prefix before every tag and that prefix is defined at the beginning of the XML. It will be clear from given example:
    XML UI5 Example
    Here we have used two different libraries: sap.m and sap.ui.layout and hence gave them the namespace as m and l.
    Default Namespace: You can make one of your namespace as default. Suppose, we make sap.m as default library. In that case, we will not give it any namespace and also none of the tags that comes under sap.m library will carry namespace ‘m’. The same thing is implemented in the code below:


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.