XML - Extensible Markup Language

Sanjana
3 min readAug 2, 2021

1.Why do we need XML?

  • Consider a scenario at an ATM, we have an ICICI bank card which we want to use at Citibank ATM, so what are the pointers that the Citibank application needs? It requires information from ICICI bank in order for both applications to be able to talk to each other. Therefore ICICI Bank will send data, say Customer ID, Name and Balance Amount in a CSV(comma separated value format) to Citi Bank. Do you see any challenges here so far?
  • Yes understanding the data received, the CSV file would look like(1000,Sanj,50000). How would Citibank understand what is 1000, Sanj and 50000 in this case? What does this received data represent? Clearly need a standard method to access information, making it easier for applications and devices of all kinds to use, store, transmit, and display data.

2. What is XML? Is it a programming language?

  • XML is used to transfer data from one application to another application. It gives a metadata about data(information about data). So it is a language but not a programmable one. We call it a data exchange language or language for communication of applications. The data is exchanged when an application has taught the other application. Eg: Sending email from gmail to yahoo. We can say it’s purpose is to make data understandable across any web applications.

3. Structure of XML Document:

i) XML Declaration:

  • The basic XML declaration only needs the language and the version. XML declaration is a processing instruction that helps in identifying the document as XML, XML declaration is optional but if its used it should be the first statement in XML( should include language and the version number).
  • 1st statement XML Declaration: <?xml version=”1.0" encoding=”UTF-8"?>
    <? indicates that the markup is a XML declaration rather than a HTML tag.
  • Sample format: Every data is given within tags (tags are user defined)<name>Sanjana</name>
  • Well formedness is the key to proper format XML, should have one root element and tags must be in proper syntax, attributes in double quotes, no compiler.
    Well formed and valid XML:
    An XML document which follows correct syntax rules is named as a well formed XML document. A well formed XML document is called a valid XML document.

ii. Root element:

  • Root element is the first element of he XML document which will contain the other elements in it. Every XML document should have a single root element.
<?xml version=”1.0" encoding=”UTF-8"?>
<person>
<name>Sanjana</name>
<gender>Female</gender>
</person>

iii. Child elements:

  • An XML can have multiple child elements. In the example above <person> is the root element here and can have ’n’ child elements <name>and <gender> are the child elements.
  • Additional information to the tag can be provided through attributes, attributes should be quoted(can be single or double quoted). Attributes are always declared as simple types
<person>
<person id=”123">
</person>
Syntax: <xs:attribute name=”name” type=”type”/> name and type are the same as for xs:element.

Other attributes a simple element may have are:

  • default=”default value” if no other value is specified
  • fixed=”value” no other value may be specified
  • use=”optional” the attribute is not required(default)
  • use=”required” the attribute must be present
  • Notes declared within the XML will describe the XML elements and attributes, It is not interpreted by the XML processor.
    <!--XML comments -->
  • XHTML: Extensible hypertext markup language, it is used for presentation aspects, HTML is enhanced as XHTML. It adheres to the rules of XML.
  • DTD: Document Type Definition checks well formedness i.e. if only one root element is there and if all open tags are closed.
  • Schema: An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself.
  • Namespace: A Namespace is a set of unique names. Namespace is a mechanisms by which element and attribute name can be assigned to a group. The Namespace is identified by URI(Uniform Resource Identifiers).

4. History of XML

  • XML is a descendant of SGML, the Standard Generalized Markup Language it is a standard for defining generalized markup language for documents (manages technical documents effectively). SGML was invented by Charles F. Goldfarb, Ed Mosher, and Ray Lorie at IBM in the 1970s and developed by several hundred people around the world until its eventual adoption as ISO standard 8879 in 1986. Markup is a text document with tags that the browser displays. XML first appeared in 1998.

-Sanjana

--

--

Sanjana

Software Engineer, here to share my journey as I embark into the World of Technology | Product Enthusiast