Revision: 44547
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 14, 2011 00:36 by anarres
Initial Code
from xml.etree import ElementTree as ET import re def strip_whitespace(my_string): """Removes spaces, tabs, and newline characters from a string. \s matches any whitespace character, this is equivalent to the class [\t\n\r\f\v].""" return re.sub("\s", "", my_string) my_xml = """ <root> <child>One</child> <child>Two</child> </root> """ my_xml = strip_whitespace(my_xml) element = ET.XML(my_xml) for subelement in element: print subelement.text
Initial URL
Initial Description
Initial Title
Parsing XML using's Python's ElementTree
Initial Tags
python, xml
Initial Language
Python