top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Evolution of XML

0 votes

Evolution of XML

In order to address the issues raised by earlier markup languages, the Extensible Markup Language (XML) was created XML is a W3C recommendation.

XML is a set of rules for defining semantic tags that break a document into parts and identify the different parts of the document. XML was developed over HTML because of the basic differences between them.



HTML was designed to display data.

XML was designed to carry data.

HTML displays data and focuses on how data looks.

XML describes data and focuses on what data is.

HTML displays information.

XML describes information.

                                  FIG: Difference between HTML and XML

An XML code:

<?xml version=”1.0” encoding=”iso-8859-1”?>




    <description> A bright brown fox jumps over the lazy dog</description>



Features of XML

Features of XML are as follows:

  • XML stands for Extensible Markup Language

  • XML is a markup language much like HTML

  • XML was designed to describe data

  • XML tags are not predefined. You must define your own tags

  • XML uses a DTD or an XML Schema to describe the data

  • XML with a DTD or XML Schema is designed to be self-descriptive

XML Markup

XML markup defines the physical and logical layout of the document. XML can be considered as an information container. It contains shapes labels. Structures and also protects information. XML employs a tree-based structure to represent a document. The basic foundation of XML is laid down by symbols embedded in the text known as markup. The markup combines the text and extra information about the text such as its structure and presentation. The markup divides the information into a hierarchy of character data and container-like elements and its attributes. A number of software programs process electronic documents use a markup.

XML’s markup divides a document into separate information containers calld elements. A document consists of one outermost element called root element that contains all the other elements. Plus some optional administrative information at the top. Known as XML declaration. Following code demonstrates the elements.

Code Snippet:

<?xml version=”1.0” encoding=”iso-8859-1” ?>




      <Description>Red in color</Description>




<Name>, <Price>, <Description> and <Number> inside the tags are elements.

<FlowerPlanet> and </FlowerPlanet> are the root elements.

The usage of XML can be observed in many real-life scenarios. It can be used in the fields of information sharing, single application usage, content delivery, re-use of data, separation of data and presentation, semantics, and so forth. News agencies are a common place where XML is used. News producers and news consumers often use a standard specification name XMLNews to produce, retrieve, and relay information across different systems in the world.

Note: XML is a subset of SGML, with the same goals, but with as much of the complexity eliminated as possible. This means that any document which follows XML’s syntax rules will also follow SGML’s syntax rules, and can therefore be read by existing SGML tools.

posted Sep 5, 2017 by Ayush Srivastav

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button

Related Articles

This article describes how to transform the XML output of SQL query statements using FOR XML AUTO to HTML using XSLT.

Normally, we execute the query using ExecuteNonQuery statement and fill the output into a data table. We can access the data in the data table by giving column name and row number in the looping method. This makes us work on extra coding and takes a lot of time to get the correct data from executed query. So, I moved to XML because, in XML, we can fetch the values easily and quickly without writing too much code.     

FOR XML Clause in SQL

Basically, we have four types of FOR XML clause in SQL.


Each of the above types satisfies its own need. When you want full control over the produced XML, you use FOR XML EXPLICIT, but it is difficult to understand, read, or maintain. FOR XML AUTO produces the most readable SELECT statement. The RAW option is rarely used and therefore not discussed. The PATH option allows you to mix attributes and elements easier. Here, I gona use FOR XML AUTO.

Table Name - Contact_Details


If we want the output as in XML format, we need to add the FOR XML AUTO statement.


  1. SELECT * FROM Contact_Details FOR XML AUTO  

This query gives the output like,

  1. < Contact_Details Contact_ID=’001’ Contact_Number=’ 088888888’ Contact_Name=’Mohan’ Contact_Location=’Chennai’/>  
  2. < Contact_Details Contact_ID=’002’ Contact_Number=’ 099999999’ Contact_Name=’Abilash’ Contact_Location=’Bangalore’/>  

The XML which we got in output is not in user-friendly format. We need each field as an attribute so, that we can access the values using XPATH. To achieve that, we need to add the ELEMENTS parameter with the query.



This query gives the output like,

  1. < Contact_Details>  
  2.     <Contact_ID>001</Contact_ID>  
  3.     <Contact_Number>088888888</Contact_Number>  
  4.     <Contact_Name>Mohan</Contact_Name>  
  5.     <Contact_Location>Chennai</Contact_Location>  
  6. </ Contact_Details>  
  7. < Contact_Details>  
  8.     <Contact_ID>002</Contact_ID>  
  9.     <Contact_Number>099999999</Contact_Number>  
  10.     <Contact_Name>Abilash</Contact_Name>  
  11.     <Contact_Location>Bangalore</Contact_Location>  
  12. </ Contact_Details>  

So, this is the exact XML format we need.

Now, we are going to create XML DOCUMENT and write this output XML into that XML document in coding. To read the query in XML format, we need to execute the query using ExecuteXmlReader() function. 

  1. XmlReader XMLReader = new XmlReader();  
  2. XmlDocument XmlDoc = new XmlDocument();  
  3. SqlCommand Cmd = new SqlCommand(Query, Conn);  
  4. XMLReader = cmd.ExecuteXmlReader();  
  5. XPathDocument xPathDoc = new XPathDocument(XMLReader);  
  6. XPathNavigator xPathNavi = xPathDoc.CreateNavigator();  
  7. XmlDoc.LoadXml(XpathNavi.OuterXml);  

Now, we got the full structured XML Document. Using this, we will transform the data into HTML format using XSLT.

Before transforming, we need to create one XSLT file to assign the values from XMLDocument to HTML format.


  1. <?xml version=”1.0” encoding=”utf-8”?>  
  2. <xsl:stylesheet version=”1.0” xmlns:xsl=””>  
  3.     <xsl:output method=”xml” indent=”yes” omit-xml-declaration=”yes”>  
  4.         <xsl:template match=”/*”>  
  5.             <table>  
  6.                 <tr>// Column heading  
  7.                     <td>ContactID</td>  
  8.                     <td>ContactNumber</td>  
  9.                     <td>ContName</td>  
  10.                     <td>ContactLocation</td>  
  11.                 </tr>  
  12.                 <xsl:for-each select=”/ Contact_Details”>  
  13.                     <tr>// inserting XML data into HTML table  
  14.                         <td>  
  15.                             <xsl:value-of select=”/Contact_details/Contact_ID” </td> // using XPath we can access the value from XML Document  
  16.                                 <td>  
  17.                                     <xsl:value-of select=”/Contact_details/Contact_Number” </td>  
  18.                                 <td>  
  19.                               <xsl:value-of select=”/Contact_details/Contact_Name” </td>  
  20.                           <td>  
  21.                        <xsl:value-of select=”/Contact_details/Contact_Location” </td>  
  22.                     </tr>  
  23.                 </xsl:for-each>  
  24.             </table>  
  25.         </xsl:template>  
  26. </xsl:stylesheet>  

Now, we have XML Document and XSLT file. In the next step, we are going to transform the XML Document into HTML using XSLT. To do this, we pass the XMLDocument and XSLT file to separate functions and get fully formed HTML strings in return.

  1. Public static string TransformXMLTOHTML(XmlDocument XMLDoc, String XSLTFilename) {  
  2.     StringWriter HTMLString = new StringWriter();  
  3.     XslCompiledTransform Xmltransform = new XslCompiledTransform();  
  4.     XmlTransform.Load(XSLTFilename); // Load XSLT File  
  5.     Xmltranform.Transform(XMLDoc, null, Result); // transform XML into HTML  
  6.     Return HTMLString.ToString();  
  7. }  
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.