XML basics

Dec 05, 2016 pm 01:26 PM

 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

  

 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1653
14
PHP Tutorial
1251
29
C# Tutorial
1224
24
Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? How to use CSS3 and JavaScript to achieve the effect of scattering and enlarging the surrounding pictures after clicking? Apr 05, 2025 am 06:15 AM

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

HTML, CSS, and JavaScript: Essential Tools for Web Developers HTML, CSS, and JavaScript: Essential Tools for Web Developers Apr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

How to implement adaptive layout of Y-axis position in web annotation? How to implement adaptive layout of Y-axis position in web annotation? Apr 04, 2025 pm 11:30 PM

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

See all articles