XML & Python (Cont’d)

I have been fighting with XML. Here is the code I’ve been trying to run in Python.


(My apologies for including this as <img>. As soon as I have my blog running under my own domain, it will hopefully be easier to format code using the Google Syntax Highlighter for WordPress.)

The file I was using this time looks like this:

<?xml version=”1.0″?>




and the successful output looks like this:

Found Name
Found Northing
Found Easting
Found Name
Found Northing
Found Easting
Found Name
Found Northing
Found Easting
Borehole  B-1 has a Northing of 10342486 and Easting of 3259140
Borehole  B-2 has a Northing of 10342671 and Easting of 3259434
Borehole  B-3 has a Northing of 10342542 and Easting of 3259375

So what I have I learned ? I can now read the gINT created XML files into Python and turn the data into objects created from my existing classes. (Granted the POINT class used here is VERY basic.) I will probably have to re-write some of the def’s for the classes in my Project module so that I can use the same code for creating an instance, whether the data came from key board entry or was read from XML, and I need to reverse the process and let my program write XML. In fact, somewhere I read about the xml_pickle module. Will have to look at that, too.

Here is a short list of links to some helpful pages :

A Technical Introduction to XML

More XML Basics

Columns by Uche Ogbuji

Understanding XML (Python & XML)

A Brief History of SAX

Charming Python #2 (XML.DOM Module)

On the ‘Pythonic’ treatment of XML documents as objects

A Summary fo XML.SAX Exceptions


Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s