using eclispe and e = xml.etree.ElementTree.parse - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: using eclispe and e = xml.etree.ElementTree.parse (/thread-7448.html) |
using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 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 RE: using eclispe and e = xml.etree.ElementTree.parse - Larz60+ - Jan-11-2018 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 ?? RE: using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 RE: using eclispe and e = xml.etree.ElementTree.parse - Larz60+ - Jan-11-2018 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 RE: using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 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. RE: using eclispe and e = xml.etree.ElementTree.parse - Larz60+ - Jan-11-2018 I knew that from the console output at bottom of image. RE: using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 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 RE: using eclispe and e = xml.etree.ElementTree.parse - snippsat - Jan-11-2018 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. RE: using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 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. RE: using eclispe and e = xml.etree.ElementTree.parse - nickhere - Jan-11-2018 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 |