def parse(self, xml, strip_empty_chars=True):
        """ Parse xml source into a root node. """
        xml = xml.strip()
        raw_items = self.lex(xml)
        if raw_items: 
            for item in raw_items:
                tag_type = get_tag_type(item)
                if tag_type == START_TAG:
                    name, attrs = self.get_name_attrs_from_tag(item)
                    self.startElement(name, attrs)
                elif tag_type == END_TAG:
                    name = item[2:-1]
                    self.endElement(name)
                elif tag_type == EMPTY_TAG:
                    name, attrs = self.get_name_attrs_from_tag(item)
                    self.startElement(name, attrs)
                    self.endElement(name)
                elif tag_type == COMMENT_TAG:
                    pass # ignore
                elif tag_type == DECL_TAG:
                    self.declaration = item
                elif tag_type == DOCTYPE_TAG:
                    pass # ignore
                else:
                    if strip_empty_chars == True:
                        item = item.strip()
                    self.characters(item)

        return self.root
 Parse xml source into a root node. 
recipes/Python/579133_MicroXml_Standalone_library_basic_XML/recipe-579133.py