Processing Instructions

The next line in the CarParts.xml file is

<?supplierformat format="X13" version="3.2"?>

This is called a processing instruction (PI). A PI is a way for you to enter information in the XML document for a specific application. A PI takes the form <?target data?>, where target is the target application expected to do the processing, and data is the information passed on to the application for processing. In our example, when CarParts.xml is parsed by the parser application, it will pass on format="X13" version="3.2" to another application called supplierformat.

You need to keep in mind the following rules while working with PIs:

  • The data can be null or may contain spaces.

  • There should not be any space between <? and the ...

Get Java™ APIs for XML Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.