Skip to Main Content
Python & XML
book

Python & XML

by Christopher A. Jones, Fred L. Drake
December 2001
Intermediate to advanced content levelIntermediate to advanced
380 pages
11h 54m
English
O'Reilly Media, Inc.
Content preview from Python & XML

Creating an XML Data Store

The third component of the distributed application built in this chapter is an “Offers XML Data Store.” This is a content-based repository of “special offers” that retailers commonly offer to their customers. In this imaginary application, the Offers Data Store holds various offers, which are retrievable from the network at runtime. Different distributed applications can access the offers for different reasons.

For example, a web-based application may want to access the offers dynamically to present offers to users based on their recent purchases or spending habits. The web application applies a stylesheet to the offer information prior to displaying on a web page. Or, it’s possible that an Intranet application may access the offers as part of management functionality in order to change or edit offers.

To that end, in this section, we construct an XML Offers Data Store. In the following section, we construct another Python class similar to CustomerProfile, which allows us to access the XML data store on the network rather transparently.

A Large XML File

The Offers Data Store consists of a large XML document residing on disk. The aforementioned access component developed later will take care of traversing this file and returning the correct offers back to the caller. The basic structure of an offer as empty elements is:

<offer>
  <id/>
  <internal-name/>
  <heading/>
  <description/>
  <discount/>
  <discount-type/>
  <expires/>
  <disclaimer/>
</offer>

A complete starting ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XML Processing with Python

XML Processing with Python

Sean McGrath
Python One-Liners

Python One-Liners

Christian Mayer

Publisher Resources

ISBN: 0596001282Supplemental ContentErrata Page