The Basics Of XML: In Simple Words

Hello, everyone. This is my first tutorial on programming series. On this lesson, I will provide knowledge about some simple concept, syntax, and basics of XML that a beginner must know.
XML is a meta-markup language that stands for Extensible Markup Language. It was developed by W3C (World Wide Web Consortium). It is used to provide a structure (design) to website pages.
But first what is a markup language?
Markup languages are such type of languages that are designed for the layout, structure, and design of text and can be understood by both human and machine. Simply they are used to give shape, size, and decoration to texts and web content. HTML and XML are some common examples markup language.
The use of XML is found in Blogspot (Blogger) templates. Designers use this language to create a beautiful theme and provide a new look to their websites. It is saved in .xml format but can be stored in other text formats like .txt by specifying its Unicode. From this, you can understand that XML is widely used in web designing.
But be clear that XML is not a programming language. It is not used to develop any programs, software or algorithms as it does not qualify and neither does it performs any calculations nor follows any rules of programming.
Recommended to read:
1.How to properly add Google analytics code on Blogger (2017 Update)
2. 6 Things To Do After Changing Domain Name
Basics Components of XML For Beginners
Writing XML is easy. But it has its own set of components and rules that should be followed to implement properly.
Let's start from the beginner's zone to write an XML document. Before learning about syntax and other advanced things, you must learn how to start and end a document which I will make you clear on this lesson.
1. XML Elements
A XML document is made by various XML nodes, also known as XML tags or XML elements that are enclosed by brackets "<" and ">". Take a look:
A XML document is made by various XML nodes, also known as XML tags or XML elements that are enclosed by brackets "<" and ">". Take a look:
<element>
</element>
Or
<element/>
Remember that XML elements are case sensitive. For example <element> and
One XML element may contain many other XML elements called its "children elements" that should not overlap. The following is incorrect form of XML:
<contact-info>
<name>Max Dai
</contact-info>
</name>
The above XML can be corrected in following ways:
<contact-info>
<name>Max Dai</name>
</contact-info>
This syntax rule is called nesting of elements.
In above example, <contact-info>...</contact-info> and <name>...</name> are the XML tags that set the start and end of document whereas "Max Dai" is the text value.
Ads:

2. XML Declaration
An XML document starts by specifying version and encoding which is called XML declaration. It should be written in the first line of XML document as whole. It is your choice whether you declare an XML document or not but whenever you do so write it on top of document in first line.
Following is an example of XML declaration:
<?xml version="1.0" encoding="UTF-8" ?>
In above xml declaration, every element like xml, version and encoding are case sensitive which should be written in lower-case. However, their values can be written in upper case. For example "UTF-8" is the element value of element "version" that can be written in upper case. XML Declaration is always optional.
Note: The value of element or tag must be enclosed in quotes (double inverted commas) as shown in above example.
Encoding:
Here I have simplified the meaning of encoding in the following ways:
A word is formed by a combination of various characters. For example, the word "He" is formed by two alphabets "H" and "e" which are technically called characters. Characters make words and different words form a sentence. This is quite a set of rule in grammar which we easily understand.
But the machine does not understand the script we use to write those characters. Be clear that I am not talking about the script used in movies. I am denoting about the font used. For example, the Devanagari and Chinese script.
If you type such characters without specifying encoding then the output will be garbage. You will find some bunch of misconfigured words on the screen. The machine is so stupid without human assistance that it does not understand English as well.
So to help the machine understand, we use character encoding declaration for a different font. They convert various codes into words. For example, to write the Devanagari alphabet "क" we use "UTF-16" encoding. If we write "क" without specifying its Unicode then the machine will show different output. But if we specify the Unicode "UTF-16" before writing the document and then the output will be "क". Generally, we write our XML document in "UTF-8" encoding.
A word is formed by a combination of various characters. For example, the word "He" is formed by two alphabets "H" and "e" which are technically called characters. Characters make words and different words form a sentence. This is quite a set of rule in grammar which we easily understand.
But the machine does not understand the script we use to write those characters. Be clear that I am not talking about the script used in movies. I am denoting about the font used. For example, the Devanagari and Chinese script.
If you type such characters without specifying encoding then the output will be garbage. You will find some bunch of misconfigured words on the screen. The machine is so stupid without human assistance that it does not understand English as well.
So to help the machine understand, we use character encoding declaration for a different font. They convert various codes into words. For example, to write the Devanagari alphabet "क" we use "UTF-16" encoding. If we write "क" without specifying its Unicode then the machine will show different output. But if we specify the Unicode "UTF-16" before writing the document and then the output will be "क". Generally, we write our XML document in "UTF-8" encoding.
Final Words:
On my future article, I will be writing about the attributes and XML document. Make sure that you subscribe via email to get notifications whenever I publish. How was this information to you? Let me know in comments section below.
Comments
Post a Comment
I Appreciate your Valuable FeedBack. So Please Don't SPAM.
Please don't use any kinds of links in comment body unless it is necessary and don't use any brand names in name field.
Thanks,
MAYAPRAKASH