I actually wrote a library that does things exactly the way you imagined it. The library is called "xe" and you can get it from: http://home.avvanta.com/~steveha/xe.html
xe can import XML to let you work with the data in an object-oriented way. It actually uses xml.dom.minidom to do the parsing, but then it walks over the resulting tree and packs the data into xe objects.
EDIT: Okay, I went ahead and implemented your example in xe, so you can see how it works. Here are classes to implement the XML you showed:
import xe
class Node(xe.TextElement):
def __init__(self, text="", value=None):
xe.TextElement.__init__(self, "node", text)
if value is not None:
self.attrs["value"] = value
class Root(xe.NestElement):
def __init__(self):
xe.NestElement.__init__(self, "root")
self.node = Node()
And here is an example of using the above. I put your sample XML into a file called "example.xml", but you could also just put it into a string and pass the string.
>>> root = Root()
>>> print root
<root/>
>>> root.import_xml("example.xml")
<Root object at 0xb7e0c52c>
>>> print root
<root>
<node value="30">text</node>
</root>
>>> print root.node.attrs["value"]
30
>>>
Note that in this example, the type of "value" will be a string. If you really need attributes of another type, that's possible too with a little bit of work, but I didn't bother for this example. (If you look at PyFeed, there is a class for OPML that has an attribute that isn't text.)