XML help

Fredrik Lundh fredrik at pythonware.com
Mon Mar 18 17:35:32 EST 2002


Vincent Foley wrote:
> I have a XML document <http://freshmeat.net/projects-xml/vim/vim.xml>.
> I want to put the latest_version value in a variable.  How would I do
> that?

here's yet another way to do it:

    from xmltoys.ElementTree import parse

    tree = parse("vim.xml")
    project = tree.getroot().find("project")
    latest_version = project.find("latest_version").text

    for elem in project:
        print elem.tag, elem.text

download: http://effbot.org/downloads/
overview: http://effbot.org/guides/element-trees.htm

</F>

<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list