def replace_by_xml(self, xml_str, el_idx=0):
        """Replace element.

        Select element that has the same name as ``xml_str``, then replace the selected
        element with ``xml_str``

        - ``xml_str`` must have a single element in the root.
        - The root element in ``xml_str`` can have an arbitrary number of children.

        Args:
          xml_str : str
            New element that will replace the existing element.

        """
        root_el = self.parse_xml(xml_str)
        self.replace_by_etree(root_el, el_idx)