python mxl.dom

# -*- coding:sjis -*-
# domの要素を表示するサンプル
from xml.dom.minidom import parse

def printNodeAttribute(node):
    a = node.attributes
    if a == None: return
    for i in range(a.length):
        na = a.item(i)
        print "\t", na.nodeName, na.nodeValue

def printNode(node):
    for n in node.childNodes:
        if n.nodeType == node.TEXT_NODE:
            d = n.data.split()
            if d: print "data: ", d
        else:
            print "node: ", n.nodeName
        printNodeAttribute(n)
        printNode(n)

dom = parse('cube.xml')
printNode(dom)