Element tree errors

John Machin sjmachin at lexicon.net
Mon May 14 06:27:42 EDT 2007


On May 14, 7:56 pm, saif.shak... at gmail.com wrote:
> HI,
>        The following code is for replacing the strings localid with
> "datapackageid" in an xml document.:
>
> from xml.etree.ElementTree import ElementTree as et

Note there are *two* occurrences of ElementTree in what you have
above. The first is the *module* with the parse function that that you
are looking for. The second is a *class*.

Try this:

import xml.etree.ElementTree as et
input_xml = open(file_input,'r')
tree = et.parse(input_xml)

or this:

from xml.etree.ElementTree import parse
input_xml = open(file_input,'r')
tree = parse(input_xml)







More information about the Python-list mailing list