Serialises the FoLiA element to XML, by returning an XML Element (in lxml.etree) for this element and all its children. For string output, consider the xmlstring() method instead.
962082
def xml(self, attribs = None,elements = None, skipchildren = False):
        """"""
        E = ElementMaker(namespace=NSFOLIA,nsmap={None: NSFOLIA, 'xml' : "http://www.w3.org/XML/1998/namespace"})

        if not attribs: attribs = {}
        if not elements: elements = []

        if self.id:
            attribs['id'] = self.id
            try:
                w = self.doc[self.id]
                attribs['t'] = w.text()
            except KeyError:
                pass

        e  = makeelement(E, '{' + NSFOLIA + '}' + self.XMLTAG, **attribs)
        return e
480172
public String toXml(Object root, String encoding) {
        try {
            StringWriter writer = new StringWriter();
            createMarshaller(encoding).marshal(root, writer);
            return writer.toString();
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
974047
def to_xml_string(str = '')
      str << ('<patternFill patternType="' << patternType.to_s << '">')
      if fgColor.is_a?(Color)
        fgColor.to_xml_string str, "fgColor"
      end

      if bgColor.is_a?(Color)
        bgColor.to_xml_string str, "bgColor"
      end
      str << '</patternFill>'
    end
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'))
573168
def to_xml
			result_string = String.new
			result_string << "<results>\n"
			@results.each do |result|
				result_string << "\t<vtresult>\n"
				RESULT_FIELDS.each{|field|
					result_string << "\t\t<#{field.to_s}>#{result[field]}</#{field.to_s}>\n" unless field == :permalink and result['permalink'].nil?
				}
				result_string << "\t</vtresult>\n"
			end if @results != nil
			result_string << "</results>\n"

			result_string
		end
468881
def xml_output(f):
    

    @wraps(f)
    def xml_output_inner_fn(*args, **kwargs):
        ret_val = f(*args, **kwargs)

        if isinstance(JobContext.get_current_context(), WebJobContext):
            JobContext.get_current_context().add_responder(
                MimeSetterWebTaskResponder('text/xml'))
        return ret_val

    return xml_output_inner_fn
518841
def __get_xml_text(root):
    
    txt = ""
    for e in root.childNodes:
        if (e.nodeType == e.TEXT_NODE):
            txt += e.data
    return txt
800700
def _tree_to_string(cls, root_element, xml_declaration=True, pretty_print=True):
        
        from lxml import etree
        return gf.safe_unicode(etree.tostring(
            root_element,
            encoding="UTF-8",
            method="xml",
            xml_declaration=xml_declaration,
            pretty_print=pretty_print
        ))
743896
def to_xml(self, f=None):
        
        if not f:
            from tempfile import TemporaryFile
            f = TemporaryFile()
        print >> f, '<?xml version="1.0" encoding="UTF-8"?>'
        print >> f, '<Domain id="%s">' % self.name
        for item in self:
            print >> f, '\t<Item id="%s">' % item.name
            for k in item:
                print >> f, '\t\t<attribute id="%s">' % k
                values = item[k]
                if not isinstance(values, list):
                    values = [values]
                for value in values:
                    print >> f, '\t\t\t<value><![CDATA[',
                    if isinstance(value, unicode):
                        value = value.encode('utf-8', 'replace')
                    else:
                        value = unicode(value, errors='replace').encode('utf-8', 'replace')
                    f.write(value)
                    print >> f, ']]></value>'
                print >> f, '\t\t</attribute>'
            print >> f, '\t</Item>'
        print >> f, '</Domain>'
        f.flush()
        f.seek(0)
        return f
276635
def xmlprint(element):
    
    if isinstance(element, (etree._Element, etree._ElementTree)):
        print etree.tostring(element, pretty_print=True)
    else:
        if hasattr(element, 'xml'):
            print etree.tostring(element.xml, pretty_print=True)
477105
public XMLString xstr()
  {
    if(null == m_xmlStr)
      m_xmlStr = m_DTMXRTreeFrag.getDTM().getStringValue(m_dtmRoot);
    
    return m_xmlStr;
  }
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
370181
def to_xml_string(str = '')
      [:col, :colOff, :row, :rowOff].each do |k|
        str << ('<xdr:' << k.to_s << '>' << self.send(k).to_s << '</xdr:' << k.to_s << '>')
      end
    end
1202118
def serialize(element, strip=False):
    
    text = etree.tostring(element, method='text', encoding='utf-8')
    if strip:
        text = text.strip()
    return str(text, encoding='utf-8')
745677
public static String serialize(String xmlString) {
        Writer sw = new StringBuilderWriter();
        serialize(asStreamSource(xmlString), sw);
        return sw.toString();
    }
927583
def fromstring(cls, root_name, data):
        
        try:
            return cls(root_name, cElementTree.fromstring(data))
        except _ETREE_EXCEPTIONS as error:
            raise InvalidXMLError(
                '"{}" XML is not parsable. Message: {}'.format(
                    root_name, error.message
                )
            )
988665
def toString( self ):
        
        # convert the element tree information
        from xml.etree import ElementTree
        
        xelem = ElementTree.Element('colorset')
        xelem.set('name', self.name())
        xelem.set('colorGroups', ','.join(self.colorGroups()))
        
        for colorName, colors in self._colors.items():
            xcolor = ElementTree.SubElement(xelem, 'color')
            xcolor.set('name', colorName)
            
            for colorGroup, color in colors.items():
                xcolorval = ElementTree.SubElement(xcolor, 'value')
                xcolorval.set('group', colorGroup)
                xcolorval.set('red',    str(color.red()))
                xcolorval.set('green',  str(color.green()))
                xcolorval.set('blue',   str(color.blue()))
                xcolorval.set('alpha',  str(color.alpha()))
        
        # save the text
        return ElementTree.tostring(xelem)