What is XML? Where and When is it used?
Have you ever wondered how the e-invoicing thing works? You’ve been thinking about why we are talking about e-invoice when this blog is about XML but let me tell you one thing there are only two technologies that are mostly used worldwide when it comes to the implementation of XML and EDI, from a startup to a million-dollar business. Let's talk about XML.
XML stands for eXtensible Markup Language. It sounds similar to HTML but there is a big difference between them as HTML stands for hypertext markup language which is used to display our data to a web browser whereas XML is used to transfer that data to another computer. Because XML provides a proper method to transfer, process, store and display the data as well. Just like HTML, XML also contains tags in which data is kept but in XML we define our own tags therefore the name “eXtensible”. Before writing any tags we define the XML version and encoding to use greek characters as well. So let's not waste more time and write our first XML code to understand it well.
Below is the sample XML code for artists and their albums which must be saved as a”.xml” extension.
sampleFile.xml
You must be wondering as you write this code and you see that your output is different. But Why? When you focus on the second line of our code you will see XML stylesheet code which helps us to view XML-like HTML pages in the browser. Let’s jump into the design code for our XML.
Note: Sometimes browser doesn't show XML content cause Google chrome and some browsers have updated their policies for some security reasons but that is not a problem we just have to run the following command in the chrome folder where we are having our chrome.exe file
chrome.exe --allow-file-access-from-files
The below code is for displaying our XML file “sampleFile.xml” in the browser which must be saved as extension “.xsl” extension. this.XSL
The above code contains version and encoding tags as it is important for browsers and the second tag contains the original filename for which the style has applied. We must add a namespace for avoiding the collision of our tags. After that, we are using HTML for displaying the data in the browser with the help of the foreach loop attribute of the XSL tag and with the help of the” value of” attribute.