Introduction to XML
We're starting the XML series. In this article, we explain what XML is with examples.
What is XML?
Extensible Markup Language is developed by W3C. Starting with XML, we will examine questions like what systems can be built and why we should choose it in future articles.
In this article, we will see tags, attributes, and tree structure in XML in general.
XML is simple and flexible.
<hello>Hello, World!</hello>
XML tag format starts with <tag> and ends with </tag>. When naming tags, you cannot use !"#$%&'()*+,/;<=>?@[]^`{|}~ and cannot start with - .
XML starts with:
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<book>Yunus Emre Divani</book>
Every book has an ISBN. We add an ISBN attribute to the book element.
<?xml version="1.0" encoding="UTF-8"?>
<book isbn="9759954949">Yunus Emre Divani</book>
Let's create a root directory called book and add new elements under it to create our first tree structure.
<?xml version="1.0" encoding="UTF-8"?>
<book isbn="9759954949">
<title>Yunus Emre Divani</title>
<author role="Editor">Selim Yagmur</author>
<language>Turkish</language>
<edition>8</edition>
<date>2014-04-01</date>
</book>

Let's prepare the XML tree structure as in the table and expand our library list by adding two books.
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book isbn="9759954949">
<title>Yunus Emre Divani</title>
<author role="Editor">Selim Yagmur</author>
<language>Turkish</language>
<edition>8</edition>
<date>
<year>2014</year>
<month>04</month>
<day>01</day>
</date>
</book>
<book isbn="9753386203">
<title>Risaletun-Nushiyye Yunus Emre</title>
<author role="Translator">Prof. Dr. Umay Turkes Gunay</author>
<language>Turkish</language>
<edition>3</edition>
<date>
<year>2009</year>
<month>01</month>
<day>01</day>
</date>
</book>
</books>
We've created a quite simple and understandable library list. Of course, you'll need to customize it according to your requirements.
For example, instead of ISBN, you may need to list according to numbers you give yourself and make sales based on this. In such cases, you can make changes very quickly. You can also start by creating your own library list.
You'll notice the flexibility of XML as time progresses.
References:
- http://www.w3.org/TR/xml/
- http://www.w3schools.com/xml/