Package flickrapi :: Module xmlnode :: Class XMLNode
[hide private]
[frames] | no frames]

Class XMLNode

source code

XMLNode -- generic class for holding an XML node

>>> xml_str = '''<xml foo="32">
... <taggy bar="10">Name0</taggy>
... <taggy bar="11" baz="12">Name1</taggy>
... </xml>'''
>>> f = XMLNode.parse(xml_str)
>>> f.name
u'xml'
>>> f['foo']
u'32'
>>> f.taggy[0].name
u'taggy'
>>> f.taggy[0]["bar"]
u'10'
>>> f.taggy[0].text
u'Name0'
>>> f.taggy[1].name
u'taggy'
>>> f.taggy[1]["bar"]
u'11'
>>> f.taggy[1]["baz"]
u'12'
Instance Methods [hide private]
 
__init__(self)
Construct an empty XML node.
source code
 
__setitem__(self, key, item)
Store a node's attribute in the attrib hash.
source code
 
__getitem__(self, key)
Retrieve a node's attribute from the attrib hash.
source code
Class Methods [hide private]
 
__parse_element(cls, element, this_node)
Recursive call to process this XMLNode.
source code
 
parse(cls, xml_str, store_xml=False)
Convert an XML string into a nice instance tree of XMLNodes.
source code
Method Details [hide private]

parse(cls, xml_str, store_xml=False)
Class Method

source code 

Convert an XML string into a nice instance tree of XMLNodes.

xml_str -- the XML to parse store_xml -- if True, stores the XML string in the root XMLNode.xml