Python Forum
using eclispe and e = xml.etree.ElementTree.parse
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using eclispe and e = xml.etree.ElementTree.parse
#1
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
Reply
#2
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
??
Reply
#3
[Image: open?id=1lghLAeHTGWJvzN2oxshnZTaGFmrxmF2P]
Reply
#4
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
Reply
#5
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.
Reply
#6
I knew that from the console output at bottom of image.
Reply
#7
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
Reply
#8
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.
Reply
#9
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.
Reply
#10
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ElementTree kkrish 2 2,285 Apr-27-2019, 01:36 AM
Last Post: kkrish
  XML Parsing - Find a specific text (ElementTree) TeraX 3 4,024 Oct-09-2018, 09:06 AM
Last Post: TeraX

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020