from lxml import etree doc = etree.parse(filename) memoryElem = doc.find('memory') print memoryElem.text # element text print memoryElem.get('unit') # attribute