O'Reilly logo

Effective XML: 50 Specific Ways to Improve Your XML by Elliotte Rusty Harold

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Misuse of Processing Instructions

Clearly, processing instructions should not be used for information that is properly part of the domain of the XML application. For example, it would be inappropriate to use processing instructions to specify when and where a particular chess game was played. Markup like the following is to be eschewed.

<?xml version="1.0"?>
<?game-info date="2003-10-24" white="Jane Smith"
                              black="Alice Jones"?>
<game>
  <move>f3</move>
  <move>e5</move>
  <move>g4</move>
  <move>Qh4++</move>
</game>

Instead, additional elements and attributes should be added to the vocabulary to encode the additional information.

 <?xml version="1.0"?> <game> <date>2003-10-24</date> <white>Jane Smith</white> <black>Alice Jones</black> <move>f3</move> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required