Introduction to XML
We start the XML series. In this article, we explain what is XML with examples.
What is XML?
Extensible Markup Language is developed by the W3C. Starting with XML, we will examine questions such as how systems can be set up and why we should choose them, together with future articles.
In this article, we will see the tags, attributes, 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 !"#$%&'()*+,/;<=>?@[]^`{|}~ cannot be used and cannot start with - . Getting started with XML
<?xml version="1.0" encoding="UTF-8"?>
starts with.
<?xml version="1.0" encoding="UTF-8"?>
<book>The Divan of Yunus Emre</book>
Each book has an ISBN. We add an ISBN attribute to the book element.
<?xml version="1.0" encoding="UTF-8"?>
<book isbn="9759954949">The Divan of Yunus Emre</book>
Let's create the first tree structure by creating a root directory called a book and adding new elements under it.
<?xml version="1.0" encoding="UTF-8"?>
<book isbn="9759954949">
<name>Yunus Emre's Divan</adi>
<author task="Compiler">Selim Yağmur</author>
<language>Turkish</language>
<print>8</print>
<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">
<name>Yunus Emre's Divan</adi>
<author task="Compiler">Selim Yağmur</author>
<language>Turkish</language>
<print>8</print>
<date>
<year>2014</year>
<month>04</month>
<day>01</day>
</date>
</book>
<book isbn="9753386203">
<name>Risaletü'n-Nushiyye Yunus Emre</adi>
<author task="Translator">Prof. Dr. Umay Turkes Gunay</author>
<language>Turkish</language>
<print>3</print>
<date>
<year>2009</year>
<month>01</month>
<day>01</day>
</date>
</book>
</books>
We have created a very simple and understandable list of libraries, of course you will have to customize it according to your wishes.
For example, instead of ISBN, you may need to list according to the numbers you provide and sell on it. In such cases, you can make changes very quickly. You can start by creating your own library list.
You will notice the flexibility of XML as time progresses.
Translated from "XML'e Giriş".
Resources:
- http://www.w3.org/TR/xml/
- http://www.w3schools.com/xml/