Posted in All Posts, Semester 2

XML Syntax

After a brief Introduction to XML, now we will learn XML syntax.

File Extension

First things first, An XML file has to be saved with the .xml extension that indicates it is a XML file and it contains common information to be used on the World Wide Web (www) and elsewhere using ASCII Text.

Syntax

See the example below,

So, as you can see, the first line begins with the XML declaration and it indicates that the file is a XML file along with its version.
The tag <bookDB> which stands for Book DataBase is known as the Root Tag and any XML document can contain only one root tag.
The next tag <book> is known as child element or branch element of the parent element <bookDB>
The book tag has title and author tags as its child elements. A parent element can have multiple child elements.

Closing a tag and Adding Info

Any tag like <book> should be closed by adding a forward slash (/) after the right angle bracket like this </book> and the data or info should be placed between them.
For example, <book>My Book</book>

We hope that you found this article on XML Syntax to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

Suggested Reading

Comment your thoughts

This site uses Akismet to reduce spam. Learn how your comment data is processed.