Formats XML document as human-readable plain text.
    :param xml_str: str (Input XML str)
    :param exceptions: Raise exceptions on error
    :return: str (Formatted XML str)
500167
def format_xml(xml_str: str, exceptions: bool=False):
    
    try:
        import xml.dom.minidom
        return xml.dom.minidom.parseString(xml_str).toprettyxml()
    except Exception:
        if exceptions:
            raise
        return xml_str
353754
def parseResponseXML( xml )
      if xml
         xml.gsub!( "\r", "" ) if @ignoreCR and @ignoreCR == true
         xml.gsub!( "\n", "" ) if @ignoreLF and @ignoreLF == true
         xml.gsub!( "\t", "" ) if @ignoreTAB and @ignoreTAB == true
         xml.gsub!( "<BR/>", "&lt;BR/&gt;" ) if @escapeBR
         @qdbapi = @responseXMLdoc = REXML::Document.new( xml )
      end
   end
920030
def toxml(self):
        

        xmlstr = '<OnStart'

        chxmlstr = ''

        for action in self.actions:
            chxmlstr += action.toxml()

        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</OnStart>'
        else:
            xmlstr += '/>'

        return xmlstr
314589
def String(self, str):
        
        ret = libxml2mod.xmlTextReaderConstString(self._o, str)
        return ret
670367
def quote_xml(text):
    
    text = _coerce_unicode(text)

    # If it's a CDATA block, return the text as is.
    if text.startswith(CDATA_START):
        return text

    # If it's not a CDATA block, escape the XML and return the character
    # encoded string.
    return saxutils.escape(text)
1281157
def to_xml_string(str = '')
      super(str) do

        colors.each_with_index do |c, index|
          str << '<c:dPt>'
          str << ('<c:idx val="' << index.to_s << '"/>')
          str << '<c:spPr><a:solidFill>'
          str << ('<a:srgbClr val="' << c << '"/>')
          str << '</a:solidFill></c:spPr></c:dPt>'
        end

        @labels.to_xml_string(str) unless @labels.nil?
        @data.to_xml_string(str) unless @data.nil?
        # this is actually only required for shapes other than box 
        str << ('<c:shape val="' << shape.to_s << '"></c:shape>')
      end
    end
901352
def _get_xml(xml_str):
    '''
    
    '''
    try:
        xml_data = etree.XML(xml_str)
    # XMLSyntaxError seems to be only available from lxml, but that is the xml
    # library loaded by this module
    except etree.XMLSyntaxError as err:
        # opennebula returned invalid XML, which could be an error message, so
        # log it
        raise SaltCloudSystemExit('opennebula returned: {0}'.format(xml_str))
    return xml_data
1145357
def to_xml_string(str = '')
      str << '<xdr:oneCellAnchor>'
      str << '<xdr:from>'
      from.to_xml_string(str)
      str << '</xdr:from>'
      str << ('<xdr:ext cx="' << ext[:cx].to_s << '" cy="' << ext[:cy].to_s << '"/>')
      @object.to_xml_string(str)
      str << '<xdr:clientData/>'
      str << '</xdr:oneCellAnchor>'
    end
1117772
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<Types xmlns="' << XML_NS_T << '">')
      each { |type| type.to_xml_string(str) }
      str << '</Types>'
    end
414552
def parse(self, xml_str):
        # type: (str) -> List[EndpointDescription]
        
        # Parse the document
        root = ElementTree.fromstring(xml_str)
        if root.tag != TAG_ENDPOINT_DESCRIPTIONS:
            raise ValueError("Not an EDEF XML: {0}".format(root.tag))

        # Parse content
        return [
            self._parse_description(node)
            for node in root.findall(TAG_ENDPOINT_DESCRIPTION)
        ]
211183
def to_str(self):
        
        return etree.tostring(self.root, xml_declaration=True,
                              standalone=True,
                              pretty_print=True)
272430
def _extractErrorString(request):
        
        errorStr = ""

        tag = None

        # noinspection PyBroadException
        try:
            # parse XML return
            root = ET.fromstring(request.text.encode('utf-8'))
            tag = root[0][0]
        except:
            # return an empty string as we can not parse the structure
            return errorStr

        for element in tag.getiterator():
            tagName = element.tag.lower()

            if tagName.endswith("string"):
                errorStr += element.text + " "
            elif tagName.endswith("description"):
                errorStr += element.text + " "

        return errorStr
924066
def writexml(self, filename_or_file=None, indent="  ", newl=os.linesep, 
                 encoding="UTF-8"):
        
        if not filename_or_file:
            filename_or_file = self.filename
        if isinstance(filename_or_file, (str, unicode)):
            filename_or_file = open(filename_or_file, "wb")
        xmlstr = self.toxml(indent, newl, encoding)
        filename_or_file.write(xmlstr)
        filename_or_file.close()
352164
public static Document parseXml(String xmlStr) {
		if (StrUtil.isBlank(xmlStr)) {
			throw new IllegalArgumentException("XML content string is empty !");
		}
		xmlStr = cleanInvalid(xmlStr);
		return readXML(new InputSource(StrUtil.getReader(xmlStr)));
	}
1122449
def as_xml(self):
        
        # Build tree
        spacing = ("\n" if (self.pretty_xml) else "")
        root = Element('error', {'xmlns': I3F_NS})
        root.text = spacing
        e_parameter = Element('parameter', {})
        e_parameter.text = self.parameter
        e_parameter.tail = spacing
        root.append(e_parameter)
        if (self.text):
            e_text = Element('text', {})
            e_text.text = self.text
            e_text.tail = spacing
            root.append(e_text)
        # Write out as XML document to return
        tree = ElementTree(root)
        xml_buf = io.BytesIO()
        if (sys.version_info < (2, 7)):
            tree.write(xml_buf, encoding='UTF-8')
        else:
            tree.write(xml_buf, encoding='UTF-8',
                       xml_declaration=True, method='xml')
        return(xml_buf.getvalue().decode('utf-8'))
329369
def raw_xml(self) -> _RawXML:
        
        if self._xml:
            return self._xml
        else:
            return etree.tostring(self.element, encoding='unicode').strip().encode(self.encoding)
110687
def request_xml(url, auth=None):
    '''
    
    '''
    try:
        r = requests.get(url, auth=auth, verify=False)
        return r.text.encode('utf-8')
    except BaseException:
        logger.error("Skipping %s (error parsing the XML)" % url)
    return