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>
The following figure depicts the XML document part.
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" ?>
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:
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 ?xml>.
Examples of XML declarations
Here are some examples of XML declarations.
XML declaration without parameters:
<?xml >
XML declaration with version definition:
XML/HTML CodeCopy content to clipboard Board
<?xml version="1.0">
XML declaration with all parameter definitions:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
XML declaration with all parameter definitions using single quotes to wrap values:
<?xml version='1.0' encoding='iso-8859-1' standalone='no' ?>
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!