XML - Processing


This chapter describes the Processing Instructions (PIs). As defined by the XML 1.0 Recommendation,

"Processing instructions (PIs) allow documents to contain instructions for applications. PIs are not part of the character data of the document, but MUST be passed through to the application.

Processing instructions (PIs) can be used to pass information to applications. PIs can appear anywhere in the document outside the markup. They can appear in the prolog, including the document type definition (DTD), in textual content, or after the document.


Following is the syntax of PI −

<?target instructions?>


  • target − Identifies the application to which the instruction is directed.

  • instruction − A character that describes the information for the application to process.

A PI starts with a special tag <? and ends with ?>. Processing of the contents ends immediately after the string ?> is encountered.


PIs are rarely used. They are mostly used to link XML document to a style sheet. Following is an example −

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

Here, the target is xml-stylesheet. href="tutorialspointstyle.css" and type="text/css" are data or instructions the target application will use at the time of processing the given XML document.

In this case, a browser recognizes the target by indicating that the XML should be transformed before being shown; the first attribute states that the type of the transform is XSL and the second attribute points to its location.

Processing Instructions Rules

A PI can contain any data except the combination ?>, which is interpreted as the closing delimiter. Here are two examples of valid PIs −

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