Home > Web Front-end > HTML Tutorial > XML basics

XML basics

WBOY
Release: 2016-12-05 13:26:31
Original
1551 people have browsed it

 XML (Extensible Markup Language), Extensible Markup Language, It is a subset of SGML (Standard General Markup Language). The main function of the xml file is to be used as a program configuration file. Others include data transfer between different languages ​​and the ability to exist as a small database. XML files serve as a markup language. Like HTML (Hyper Text Markup Language), they are both based on element tags. The tree structure language has the characteristics of clear data hierarchy and universal data recognition. However, there are still differences between XML and HTML languages: 1. As an extensible language, XML language can name its tags by itself, and Tag names with Chinese names are also allowed (although garbled characters may occur during parsing); 2. XML language parsing is very complex, including different parsing methods and parsers, while HTML language parsing comes from browsing It is a static language with unified specifications and does not require us to write code for parsing.

  XML language specification:

  1. The XML file must have an xml document declaration:

<span style="color: #0000ff"><?</span><span style="color: #ff00ff">xml version="1.0" encoding="UTF-8" standalone="yes?></span>
Copy after login

 The version attribute represents the current XML version, the encoding attribute represents the encoding method of the XML file, and the standalone attribute represents whether the XML file is independent (whether it depends on external files, the default is yes)

 The document declaration must start in the first line and column of the xml file, otherwise it will be invalid

  2. Element format of XML file:

  The element format of xml is basically the same as that of html, Zhuge Liang can also have only one root element; the difference between xml elements and html is that xml will automatically Spaces and newlines are parsed, but html does not, so the tags in xml must be standardized, otherwise parsing errors may occur

  3. XML element naming convention:

  The naming convention of elements in xml: it can contain numbers, letters and some common symbols, but it must follow several principles: it cannot start with a number or an underscore; it cannot be named with keywords such as xml; it cannot contain spaces; it cannot be in the middle of the name Include":".

  4. XML element attribute declaration:

  Element attributes in XML can be defined by yourself. The specification of attribute name declaration is the same as that of element name. The declaration format of element attributes is the same as in HTML, which is xx attribute="xx value". An element can have multiple attributes, but The same attribute cannot have multiple values.

  5. Comments in XML

  Same as in html, it is , comments cannot be nested in comments

  4.XML language escape characters and CDATA area:

  The escape characters of xml are the same as those of html language. The CDATA area is used when the expression contains many escape characters. It is too troublesome to escape them one by one. Therefore, there is a special area to store such expressions instead of The area that can be parsed successfully even if you manually escape it is the CDATA area with the following format:

<span style="color: #0000ff"><!</span><span style="color: #ff00ff">[CDATA[表达式]]</span><span style="color: #0000ff">></span>
Copy after login

  5.PI instruction (processing instruction)

  The so-called PI instruction can be understood as informing the parser how to process xml content. The basic format is , such as parsing xml documents according to css style:

<span style="color: #0000ff"><?</span><span style="color: #ff00ff">xml-stylesheet type="text/css" href="a.css"</span><span style="color: #0000ff">?></span>
Copy after login

  

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template