5.1 Auction Listing XML

 < Day Day Up > 

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"?> <eBayAuctions>    <Auction>       <Category>37920</Category>       <Weight>5.0</Weight>       <MinimumBid>50</MinimumBid>       <Title>Wonderful Ancient Chinese Basket</Title>       <Description>This magnificent basket was handcrafted  by monks over one hundred years ago.</Description>       <AuctionID>4500404174</AuctionID>    </Auction>    <Auction>       <Category>2206</Category>       <Weight>50.0</Weight>       <MinimumBid>100</MinimumBid>       <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>       <AuctionID>4500404176</AuctionID>    </Auction> </eBayAuctions>

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

     < Day Day Up > 

    Real World Web Services
    Real World Web Services
    ISBN: 059600642X
    EAN: 2147483647
    Year: 2006
    Pages: 83
    Authors: Will Iverson

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net