Home >Backend Development >XML/RSS Tutorial >Detailed explanation of the code for processing instructions in XML

Detailed explanation of the code for processing instructions in XML

黄舟
黄舟Original
2017-03-10 19:37:582037browse

This article mainly introduces the processing instructions in XML. Processing instructions are not commonly used in XML. You can have a little understanding. Friends in need can refer to the

"Processing Instructions (PIs) Allowance Document Contains directives for applications. Directives are not part of the document's character data, but must be passed through the application."
Processing instructions can be used to pass information to applications. Processing instructions can appear outside the markup anywhere in the document. Can appear in the prologue, in the document's type definition (DTD), in the text content, or after the document.

Processing directives allow documents to contain directives that are processed by the application. In the XML document, there may be some non-XML format data that cannot be processed by the XML processor. We can notify other applications to process the data through processing instructions.
The syntax of processing instructions (PI) is similar to XML declarations, starting with Start with? >End. A common processing instruction using style sheets is as follows:

<?xml-styesheet herf=”hello.css” type=”text/css”?>

In the opening tag The first string after xml-styesheet is called the target of the processing instruction. It must identify the application to be used. It should be noted that other non-W3C-defined processing instructions cannot start with the strings XML and xml. The rest Part of it is character data passed to the application program. The application program obtains the target and data from the processing instructions and performs the required actions.
The target of the processing instruction can be the name of the program to be used, or an identifier similar to xml-stylesheet that many programs can recognize. Different applications support different processing instructions. Most applications ignore processing instructions that they do not recognize. For custom processing instructions, it is usually processed by a selected application. Because the processing instruction you defined is not recognized by other applications, it will be ignored.
xml-stylesheet processing instructions are always placed after the XML declaration and before the first element. Other processing instructions can be placed inside the markup and anywhere before the XML declaration.
It should be noted that although the syntax of XML declarations and processing instructions are similar, XML declarations are not processing instructions. XML processing programs adopt different processing methods for XML declarations and processing instructions.


Syntax
The following is the syntax for processing instructions:

<?target instructions?>

Where:

target - Identifies which application the instruction points to.
instruction - Characters describing the information to be processed by the application.
Processing instructions start with the special 5379ceb14907c51d9afe5c362a62b1c9. Processing ends immediately when the string ?> is encountered.

Example
Processing directives are rarely used. Mainly used to link XML documents to style sheets. The following is an example:

<?xml-stylesheet href="tutorialspointstyle.css" type="text/css"?>

Here, the target is xml-stylesheet. href="tutorialpointstyle.css" and type="text/css" are the data or instructions that the target application will use to process the given XML document.

In this case, the browser identifies the target by indicating that the XML should be transformed between displays; the first attribute states that the transformation type is XSL, and the second attribute points to its location.

Processing directive rules
Processing directives can contain any data except the ?> combination, which is interpreted as a closing directive. Here are two examples of valid processing instructions:

<?welcome to pg=10 of tutorials point?>

<?welcome?>


The above is the detailed content of Detailed explanation of the code for processing instructions in XML. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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