def _get_row_data(row, fields_xpath): row = tree_from_string(to_string(row)) data = [] for field_name, field_xpath in fields_xpath.items(): result = row.xpath(field_xpath) if result: texts = map(string.strip, map(unescape, result)) result = ' '.join(text for text in texts if text) else: result = None data.append(result) return data
def _get_content(element): return (element.text if element.text is not None else "") + "".join( to_string(child, encoding=six.text_type) for child in element.getchildren() )
def _get_content(element): content = to_string(element) content = content[content.find('>') + 1:content.rfind('<')].strip() return unescape(content)