Python Forum

Full Version: using eclispe and e = xml.etree.ElementTree.parse
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
my code is this
e = xml.etree.ElementTree.parse©.getroot()
under e in the debugger
it shows attrib
under that it shows id
and it a string value
how do I print(get) that value
what does the rest of the code look like?
which debugger?
is string value assigned to a variable?
print(string value)
or add to watches on your debugger
??
[Image: open?id=1lghLAeHTGWJvzN2oxshnZTaGFmrxmF2P]
It seems to be complaining about the indent on line 21 (which is not shown in your image.
Check and make sure that that line is indented properly
I know that but everything below that work find having issue fixing it. How did you know that?
all i need to do is print that id value.
I knew that from the console output at bottom of image.
I just notice that
shouldn't this work
e = xml.etree.ElementTree.parse©.getroot()
print(e.attrib.id)

error

AttributeError: 'dict' object has no attribute 'id'


the image debugger shows it does
Could you post some sample input code(xml) and tell what you want out,
we could probably solve it reasonably quick.
For parser i never use ElementTree,BeautifulSoup or lxml are just much better and more up to date.
I was thinking about using lxml
I may go a different way and pull the data needed out of child.
Basically I need to see if the http still up and if so does the file exist.
in the image above there is data under attrib
e = xml.etree.ElementTree.parse©.getroot()
print (e.attrib.id.value)
cant get the value for the id
error comes up
AttributeError: 'dict' object has no attribute 'id'

dummy me i coded this before in html
the fix
print (e.attrib['id'])
it the brackets and text