def parse_xml(self, xml):
        """
        parse rspec into etree
        """
        parser = etree.XMLParser(remove_blank_text=True)
	print parser
	print xml
        try:
            tree = etree.parse(xml, parser)
        except IOError:
            # 'rspec' file doesnt exist. 'rspec' is proably an xml string
            try:
                tree = etree.parse(StringIO(xml), parser)
		print StringIO(xml),xml
            except Exception, e:
                raise InvalidXML(str(e))
        root = tree.getroot()
        self.namespaces = dict(root.nsmap)
        # set namespaces map
        if 'default' not in self.namespaces and None in self.namespaces: 
            # If the 'None' exist, then it's pointing to the default namespace. This makes 
            # it hard for us to write xpath queries for the default naemspace because lxml 
            # wont understand a None prefix. We will just associate the default namespeace 
            # with a key named 'default'.     
            self.namespaces['default'] = self.namespaces.pop(None)
            
        else:
            self.namespaces['default'] = 'default' 

        self.root = XmlElement(root, self.namespaces)
        # set schema
        for key in self.root.attrib.keys():
            if key.endswith('schemaLocation'):
                # schemaLocation should be at the end of the list.
                # Use list comprehension to filter out empty strings 
                schema_parts  = [x for x in self.root.attrib[key].split(' ') if x]
                self.schema = schema_parts[1]    
                namespace, schema  = schema_parts[0], schema_parts[1]
                break
dataset/ETHPy150Open fp7-ofelia/ocf/ofam/src/src/foam/sfa/util/xml.py/XML.parse_xml/original