Created
September 12, 2012 00:25
-
-
Save waldofe/3703256 to your computer and use it in GitHub Desktop.
Xmlns simple parser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elementtree import ElementTree as ET | |
class XmlnsParser(object): | |
def __init__(self, path): | |
self.path = path | |
def tags_and_texts(self): | |
self.tags_n_text = {} | |
file = open(self.path, 'r') | |
elements = ET.parse(file) | |
for elem in elements.getiterator(): | |
self.tags_n_text.update({elem.tag: elem.text}) | |
return self.tags_n_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment