Error while parsing XML document in Python -


i'm trying write simple script parses xml document name <xs:element> tags. i'm using minidom (is there better way?) here code far:

import csv xml.dom import minidom  xmldoc = minidom.parse('core.xml') core = xmldoc.getelementsbytagname('xs:element')  print(len(core)) print(core[0].attributes['name'].value)  x in core:     print(x.attributes['name'].value) 

i'm getting error:

traceback (most recent call last): file "c:/users/user/desktop/xml parsing/test.py", line 9, in <module>    print(core[0].attributes['name'].value) file "c:\python27\lib\xml\dom\minidom.py", line 522, in __getitem__    return self._attrs[attname_or_tuple] keyerror: 'name' 


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -