Now that you know the basics, this article explains how to use XML's more advanced constructs to author complex XML documents. Entities, namespaces, CDATA blocks, processing instructions - they're all in here, together with aliens, idiots, secret agents and buried treasure.
In addition to character data, XML also allows document authors to include specific instructions or commands to the processing application within the document. These instructions are referred to as "processing instructions", or PIs. PIs are not part of character data; instead, when an XML parser encounters a PI, it simply hands it over to the calling application, which has the option of using it (if it recognizes it) or ignoring it (if it doesn't.)
Every PI includes a target - this is the string used to identify the application to which the instruction is directed - followed by some data. This target-and-data combination is enclosed with <?...?> tags, as demonstrated by the following example:
<?xml version="1.0"?>
<directory>
<category>Online Shopping<?rating
popular?></category>
<url>http://www.amazon.com</url>
<desc>Amazon.com,
the planet's foremost e-tailer<?link_with_ad ?></desc>
<url>http://www.cdnow.com</url>
<desc>CDNow.com,
for all your music</desc>
<url>http://www.bn.com</url>
<desc>Barnes
& Noble's online bookstore</desc>
</directory>
This data will be used by the XML application - for example, the first PI could
indicate that the category be marked as "popular", while the second could link the item description with an advertisement.
If you take a look at the document prolog (discussed in the last article), you'll see that the first line in any XML document,
<?xml version="1.0"?>
is actually a processing instruction.
This article copyright Melonfire 2001. All rights reserved.