XML creation

Michal Wallace sabren at manifestation.com
Fri Sep 1 03:45:40 CEST 2000

On Thu, 31 Aug 2000, Curtis Jensen wrote:

> We have several arrays, some are multidimensional arrays, created with
> NumPy.  We'd like store these arrays in an XML data structure.  Is there
> a python script similar to shelve or pickle that will take an array and
> convert it to XML code?  Thanks.

Hey Curtis,

The xmlrpc module has routines to convert structures to XML (it's on

.. But if you want more control over what the XML looks like, you
could always start with something like:

def xmlify(somearray):
    res = "<cell>"
    for item in somearray:
        if type(item)==type([]):
            res = res + xmlify(item)
	    res = res + item
    res = res + "</cell>"
    return res

print '<?xml version="1.0"?>'
print xmlify(yourMultiDimensionalArray)


- Michal
www.manifestation.com  www.sabren.com  www.linkwatcher.com  www.zike.net

More information about the Python-list mailing list