Home > Backend Development > XML/RSS Tutorial > Detailed introduction to document and declaration usage in XML

Detailed introduction to document and declaration usage in XML

黄舟
Release: 2017-03-10 19:59:49
Original
1714 people have browsed it

This article mainly introduces the usage of documents and declarations in XML. It is the basic knowledge for introductory learning of XML. Friends who need it can refer to it

An XML document is an organized element and other tags The basic unit of XML information composed of. An XML _document_ can contain a wide variety of data. For example, in a numerical database, numbers represent molecular structures or mathematical formulas.

XML Document Example
A simple XML document example is provided below:

<?xml version="1.0"?>
<contact-info>
    <name>Tanmay Patil</name>
    <company>TutorialsPoint</company>
    <phone>(011) 123-4567</phone>
</contact-info>
Copy after login


The following figure depicts the XML document part.
Detailed introduction to document and declaration usage in XML

Document Prologue
Document Prologue is at the top of the document, before the root element. This section contains:

XML Declaration

The XML declaration contains details that prepare the XML handler to parse the XML document. It is optional, but when used it must appear on the first line of the XML document.

Syntax
The following syntax shows the XML declaration:

<?xml
    version="version_number"
    encoding="encoding_declaration"
    standalone="standalone_status"
?>
Copy after login

Each parameter consists of the parameter name, the equal sign (=), and the parameter value wrapped in quotes. The following table shows the details of the above syntax:

Detailed introduction to document and declaration usage in XML

Rules
XML declarations should comply with the following rules:

If an XML declaration appears in XML , it must be placed on the first line of this XML document.
If an XML declaration is included, the version number attribute must be included.
Parameter names and values ​​are case-sensitive.
The order in which parameters are placed is important. The correct order is: version, encoding and standalone.
You can use single quotes or double quotes.
XML declaration has no closing tag, such as .

Examples of XML declarations

Here are some examples of XML declarations.

XML declaration without parameters:

<?xml >
Copy after login

XML declaration with version definition:

XML/HTML CodeCopy content to clipboard Board

<?xml version="1.0">
Copy after login

XML declaration with all parameter definitions:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
Copy after login

XML declaration with all parameter definitions using single quotes to wrap values:

<?xml version=&#39;1.0&#39; encoding=&#39;iso-8859-1&#39; standalone=&#39;no&#39; ?>
Copy after login

The above is the detailed content of Detailed introduction to document and declaration usage in XML. For more information, please follow other related articles on the PHP Chinese website!

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