5.1 Auction Listing XML

Start with a basic XML file format for writing auction posts. The goal here is to have a simple format a human can easily modify. This XML is shown in Example 5-1.

Example 5-1. Basic auctions XML
<?xml version="1.0" encoding="UTF-8"?>






      <Title>Wonderful Ancient Chinese Basket</Title>

      <Description>This magnificent basket was handcrafted 

by monks over one hundred years ago.</Description>







      <Title>Reproduction 1632 European World Map</Title>

      <Description><![CDATA[<b>Beautiful</b> cloth map of 

the world as known to western Europe in 1632 - complete 

with warnings about dragons!]]></Description>




As shown in the example, this is a straightforward XML format. There are two auctions with the category, weight, minimum bid, title, and description specified. You don't want embedded HTML to be treated as part of the structure, so the description for the second auction is wrapped in the XML escape sequence:

 <!CDATA[ ... ]]>

As shown in Figure 5-1, you can do some simple validation of the XML file in a modern web browser, which allows you to easily ensure that the file is valid XML. You can even write a DTD or XML schema to validate the file, but for trivial purposes, this will suffice.

Figure 5-1. Viewing auctions.xml