The Basic Principles of XML

0

What Are The Basic Principles of XML?

XML is a specification of WWWC that represents a set of rules that allows creating languages to transport data on the internet. He is a part of SGML, a complex specification that represents the parent of several languages of this type.

 

AN XML file is a structured text that contains:

 

Data – the data that is the subject of the transmission

Information about data – metadata – for example, the method used by data to inter-react. the meta-information is specified using certain tags, resembling with the ones from the HTML source.

 

Here is an example of a XML file

 

<?xml  version=”1.1″?> <product  id=”45″>

<name>Book</name>

<price>25</price>

</product>

 

the XML file presented here contains information about the product with the ID 45, called Book and having a price of 25. Besides that information, all the other data is metadata: the first line is the XML version, and the tags product, name and price are characterizing the information contained by the file, establishing the name and the price of the product.

Although an XML file is somewhat resembling with a HTML file, the two technologies are different in many ways:

HTML was conceived with the purpose of specifying and structuring the method of presenting the data, while XML has the purpose of memorizing the structure of data for transporting it in different systems.

HTML is a language, having a pre-established set of tags. XML is a specification that allows the programmer to define his own tags that describes the useful data and the relationship between elements.

 

The advantages of XML

The XML files are text files, therefore they have multiple advantages:

  • they are easy to understand by the human eye
  • they are readable for certain applications
  • they are independent of the software and hardware platform that works with the XML applications. There are XML libraries for any kind of software platforms, so an XML file written or generated in Windows can be read on MacOS and Linux.
  • An XML file can be considered a database that is easy to read and manipulate using already written libraries, and it can also be successfully used to transfer data between systems that are incompatible otherwise.

 

Elements and PCDATA

Let’s see the next XML file:

<person>

<name>Carl <nickname>Little one </nickname>Doyle </last name>

<age>28</age>

</person>

 

An XML tag represents the text that begins with < and ends with >. In the previous example, <person>, <name>, <nickname> and <age> are tags. The tags are generally pairs: there is a beginning and ending tag, the ending one having the same name as the beginning one. The tags are responsible to specify the structure of information.

An XML element represents the whole information contained between the ending and the finishing tag. In our example, <age> and <name> are string elements. In this case, the content of the elements is named parsed character or PCDATA.

Other sub-elements or combinations of sub-elements can be contained in a structure of this kind. They will be considered a child of the main element that is called parent.

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *