Home arrow Python arrow Working with XML Documents and Python

Working with XML Documents and Python

XML can be used for describing data without needing a database. However, this leaves us with the problem of interpreting the data embedded within the XML. This is where Python comes to the rescue, as Peyton explains.

TABLE OF CONTENTS:
  1. Working with XML Documents and Python
  2. Organizing a Book Collection
  3. Describing a Music Library
  4. The Document Object Model
By: Peyton McCullough
Rating: starstarstarstarstar / 17
November 17, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

XML, or eXtensible Markup Language, is a useful tool for describing all sorts of data. Take a look at this example:

<?xml version="1.0" encoding="UTF-8"?>
<devshed>
   <categories>
      <python>
         <article>
            <title>MySQL Connectivity With Python</title>
            <author>Icarus</author>
         </article>
         <article>
            <title>Python UnZipped</title>
            <author>Mark Lee Smith</author>
         </article>
      </python>
      <php>
         <article>
            <title>Writing Clean and Efficient PHP Code</title>
            <author>David Fells</author>
         </article>
         <article>
            <title>Using the PHP Crypt Function</title>
            <author>Chris Root</author>
         </article>
      </php>
   </categories>
</devshed>

We describe four articles in the DevShed backend. We start with a tag named devshed. Inside it, the tag categories contains two names, python and php. Inside each of these is an article tag, containing a title tag and an author tag. With this system, we are able to describe the data contained very easily and with no database. The data can be modified later with little effort and by someone with little experience.

However, we are faced with the problem of interpreting the data embedded within the XML. We need something to parse it with. Python includes a few tools that can aid us in parsing the data, and we'll take a look at them in this article, learning about them through example.



 
 
>>> More Python Articles          >>> More By Peyton McCullough
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: