My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Featured
Downloads

See also: http://lxml.de/objectify.html

For latest, please refer to https://github.com/nkchenz/lhammer

Examples

XML2Dict:

fromstring # Parse a given string
parse #Parse a given file
from xml2dict import XML2Dict

if __name__ == '__main__':
    s = """<?xml version="1.0" encoding="utf-8" ?>
    <result>
        <count n="1">10</count>
        <data><id>491691</id><name>test</name></data>
        <data><id>491692</id><name>test2</name></data>
        <data><id>503938</id><name>hello, world</name></data>
    </result>"""

    xml = XML2Dict()
    r = xml.fromstring(s)
    from pprint import pprint
    pprint(r)
    print r.result.count.value
    print r.result.count.n

    for data in r.result.data:
        print data.id, data.name 
    pprint(xml.parse('a'))

Powered by Google Project Hosting