Home >Backend Development >XML/RSS Tutorial >Do you know XML? What is it used for?
What is
?
XML, Extensible Markup Language
, extensible markup language. The suffix of the file is: .xml. Just like HTML is for displaying data, XML is for transmitting and storing data.
It is said that java is a professional language for operating XML.
What is it used for?
In order to facilitate data sharing and communication between different applications and different platforms.
The specific functions are:
(1) It can be used as a simple database to store and retrieve data;
( 2) Transmit files in the agreed format;
(3) Make software configuration files. [Configuration file: a file that saves software settings]
XML’s older brother——HTML
XML was born to improve the flaws and limitations of HTML.
The differences in usage are as follows:
XML’s best friend——JSON
JSON, Javascript Object Notation
, js object notation. The function is also to store and exchange text information.
Comparison of the two: JSON is smaller, faster, easier to parse, so, and more popular than XML.
The scope of both: JSON is suitable for simple value transfer, and XML is suitable for a wider range.
XML data structure - tree structure
How it is implemented specifically, readers can refer to the code in the example below to understand at a glance.
It is worth noting that just like a book has only one root, XML can only have one root element.
Mind Map
##ExampleCode in the
.xml file:
<?xml version="1.0" encoding="UTF-8"?> <email xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="email.xsd"> <to>liuwei8809@163.com</to> <form>hellokitty@163.com</form> <title>about loving</title> <body>I love you forever!</body> <date>2008-11-12</date> </email>
Code in the .xsd file:
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="email"> <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"></xs:element> <xs:element name="from" type="xs:string"></xs:element> <xs:element name="title" type="xs:string"></xs:element> <xs:element name="body" type="xs:string"></xs:element> <xs:element name="date" type="xs:date"></xs:element> </xs:sequence> </xs:complexType> </xs:element> </schema>
Achieved effect:
For more related questions, please visit the PHP Chinese website: XML Video Tutorial
The above is the detailed content of Do you know XML? What is it used for?. For more information, please follow other related articles on the PHP Chinese website!