Creates a string representation of the given data element tree.
19167
def data_element_tree_to_string(data_element):
    
    # FIXME: rewrite this as a visitor to use the data element tree traverser.
    def __dump(data_el, stream, offset):
        name = data_el.__class__.__name__
        stream.write("%s%s" % (' ' * offset, name))
        offset += 2
        ifcs = provided_by(data_el)
        if ICollectionDataElement in ifcs:
            stream.write("[")
            first_member = True
            for member_data_el in data_el.get_members():
                if first_member:
                    stream.write('%s' % os.linesep + ' ' * offset)
                    first_member = False
                else:
                    stream.write(',%s' % os.linesep + ' ' * offset)
                __dump(member_data_el, stream, offset)
            stream.write("]")
        else:
            stream.write("(")
            if ILinkedDataElement in ifcs:
                stream.write("url=%s, kind=%s, relation=%s" %
                             (data_el.get_url(), data_el.get_kind(),
                              data_el.get_relation()))
            else:
                first_attr = True
                for attr_name, attr_value in iteritems_(data_el.data):
                    if first_attr:
                        first_attr = False
                    else:
                        stream.write(',%s' % os.linesep
                                     + ' ' * (offset + len(name) + 1))
                    if attr_value is None:
                        continue
                    if not IResourceDataElement in provided_by(attr_value):
                        stream.write("%s=%s" % (attr_name, attr_value))
                    else:
                        stream.write("%s=" % attr_name)
                        __dump(attr_value, stream, offset)
            stream.write(')')
    stream = NativeIO()
    __dump(data_element, stream, 0)
    return stream.getvalue()
870169
function (data) {
        var tag = data.tag;
        var el = '<' + tag + '>';

        if (data.text && data.text.trim()) {
            el += data.text.trim();
        } else {
            data.getchildren().forEach(function (child) {
                el += lib.eltreeToXmlString(child);
            });
        }

        el += '</' + tag + '>';
        return el;
    }
742640
def string_to_element(element_as_string, include_namespaces=False):
    

    if element_as_string is None:
        return None
    elif isinstance(element_as_string, ElementTree):
        return element_as_string.getroot()
    elif isinstance(element_as_string, ElementType):
        return element_as_string
    else:
        element_as_string = _xml_content_to_string(element_as_string)

    if not isinstance(element_as_string, string_types):
        # Let cElementTree handle the error
        return fromstring(element_as_string)
    elif not strip_xml_declaration(element_as_string):
        # Same as ElementTree().getroot()
        return None
    elif include_namespaces:
        return fromstring(element_as_string)
    else:
        return fromstring(strip_namespaces(element_as_string))
604908
def toString(self):
        
        xprofile = self.toXml()
        projex.text.xmlindent(xprofile)
        return ElementTree.tostring(xprofile)
457812
def do_string_set(self, element, decl, pseudo):
        """"""
        args = serialize(decl.value)
        step = self.state[self.state['current_step']]

        strval = ''
        strname = None
        for term in decl.value:
            if type(term) is ast.WhitespaceToken:
                continue

            elif type(term) is ast.StringToken:
                if strname is not None:
                    strval += term.value
                else:
                    log(WARN, u"Bad string-set: {}".format(
                        args).encode('utf-8'))

            elif type(term) is ast.IdentToken:
                if strname is not None:
                    log(WARN, u"Bad string-set: {}".format(
                        args).encode('utf-8'))
                else:
                    strname = term.value

            elif type(term) is ast.LiteralToken:
                if strname is None:
                    log(WARN, u"Bad string-set: {}".format(
                        args).encode('utf-8'))
                else:
                    step['strings'][strname] = strval
                    strval = ''
                    strname = None

            elif type(term) is ast.FunctionBlock:
                if term.name == 'string':
                    str_args = split(term.arguments, ',')
                    str_name = self.eval_string_value(element,
                                                      str_args[0])[0]
                    val = self.lookup('strings', str_name)
                    if val == '':
                        if len(str_args) > 1:
                            val = self.eval_string_value(element,
                                                         str_args[1])[0]
                        else:
                            log(WARN, u"{} blank string"
                                .format(str_name).encode('utf-8'))

                    if strname is not None:
                        strval += val
                    else:
                        log(WARN, u"Bad string-set: {}".format(
                            args).encode('utf-8'))

                elif term.name == 'counter':
                    counterargs = [serialize(t).strip(" \'")
                                   for t in split(term.arguments, ',')]
                    count = self.lookup('counters', counterargs)
                    strval += str(count)

                elif term.name == u'attr':
                    if strname is not None:
                        att_args = split(term.arguments, ',')
                        att_name = self.eval_string_value(element,
                                                          att_args[0])[0]
                        att_def = ''
                        if len(att_args) > 1:
                            att_def = self.eval_string_value(element,
                                                             att_args[1])[0]
                        if '|' in att_name:
                            ns, att = att_name.split('|')
                            try:
                                ns = self.css_namespaces[ns]
                            except KeyError:
                                log(WARN, u"Undefined namespace prefix {}"
                                    .format(ns).encode('utf-8'))
                                continue
                            att_name = etree.QName(ns, att)
                        strval += element.etree_element.get(att_name, att_def)
                    else:
                        log(WARN, u"Bad string-set: {}".format(
                            args).encode('utf-8'))

                elif term.name == u'content':
                    if strname is not None:
                        strval += etree.tostring(element.etree_element,
                                                 encoding='unicode',
                                                 method='text',
                                                 with_tail=False)
                    else:
                        log(WARN, u"Bad string-set: {}".format(
                            args).encode('utf-8'))

                elif term.name == u'first-letter':
                    tmpstr = self.eval_string_value(element, term.arguments)
                    if tmpstr:
                        if isinstance(tmpstr[0], basestring):
                            strval += tmpstr[0][0]
                        else:
                            log(WARN, u"Bad string value:"
                                u" nested target-* not allowed. "
                                u"{}".format(serialize(
                                    args)).encode('utf-8'))

                elif term.name == u'pending':
                    log(WARN, u"Bad string-set:pending() not allowed. {}"
                        .format(args).encode('utf-8'))

        if strname is not None:
            step['strings'][strname] = strval
877338
def to_xml_string(str = '')
      super(str) do
        str << ("<c:" << node_name << ">")
        str << ('<c:grouping val="' << grouping.to_s << '"/>')
        str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
        @series.each { |ser| ser.to_xml_string(str) }
        @d_lbls.to_xml_string(str) if @d_lbls
        yield if block_given?
        axes.to_xml_string(str, :ids => true)
        str << ("</c:" << node_name << ">")
        axes.to_xml_string(str)
      end
    end
1313638
public static String serialize(Element element) {
        StringWriter sw = new StringWriter();
        serialize(new DOMSource(element), sw);
        return sw.toString();
    }
1173693
def tostring(self):
        """"""
        parser = etree.XMLParser(remove_blank_text=True)
        outputtree = etree.XML(etree.tostring(self.__doc), parser)
        return etree.tostring(outputtree, pretty_print=True)
854476
protected static final void toXML(StringBuilder out, int indent, boolean insertMeta, Tree node) {
		String name = node.get("_name", node.isPrimitive() ? "item" : node.getName());

		// Start XML element
		addSpaces(out, indent);
		out.append('<');
		String elementName;
		if (name == null || name.isEmpty()) {
			elementName = node.get("_name", node.getParent() == null ? "xml" : "item");
		} else {
			elementName = name;
		}
		out.append(elementName);

		// Write attributes
		for (Tree attr : node) {
			String attrName = attr.getName();
			if (!attrName.startsWith("@")) {
				continue;
			}
			out.append(' ');
			out.append(attrName.substring(1));
			out.append(EQUALS);
			writeAttribute(out, attr.asString());
			out.append('\"');
		}

		// End of XML element
		out.append('>');
		if (indent > -1) {
			out.append(CR_LF);
		}

		// Insert metadata
		if (insertMeta) {
			Tree meta = node.getMeta(false);
			if (meta != null && !meta.isEmpty()) {
				toXML(out, indent > -1 ? 2 : -1, false, meta);
			}
		}

		// Properties
		int len = out.length();
		String text = null;
		for (Tree child : node) {
			String childName = child.getName();
			if (childName.isEmpty() || node.isEnumeration()) {
				childName = "item";
			} else {
				if (childName.startsWith("@") || "_name".equals(childName)) {
					continue;
				}
				if ("_text".equals(childName)) {
					text = child.asString();
					continue;
				}
			}
			
			// BASE64
			if (!child.isPrimitive()) {
				continue;
			}
			if (indent > -1) {
				addSpaces(out, indent + 2);
			}
			out.append('<');
			out.append(childName);
			out.append('>');
			writeXMLContent(out, String.valueOf(child.asString()));
			out.append(BEGIN_END_TAG);
			out.append(childName);
			out.append('>');
			if (indent > -1) {
				out.append(CR_LF);
			}
		}
		if (text == null && node.isPrimitive()) {
			text = node.asString();
		}
		if (text == null) {

			// Write items of array
			Tree items = node.get("_items");

			if (items != null) {
				addChildren(out, indent, items, false);
			} else {
				addChildren(out, indent, node, true);
			}

			// Formatting
			if (indent > -1) {
				if (out.length() == len) {
					out.setLength(len - 2);
				} else {
					addSpaces(out, indent);
				}
			}
		} else {

			// Formatting
			if (indent > -1) {
				out.setLength(len - 2);
			}

			// Text content
			writeXMLContent(out, text.trim());
		}

		// Close element
		out.append(BEGIN_END_TAG);
		out.append(elementName);
		out.append('>');
		if (indent > 0) {
			out.append(CR_LF);
		}
	}
1230087
def tostring(self, root=None, doctype=None, pretty_print=True):
        """"""
        if root is None:
            root = self.root
        return etree.tounicode(
            root, doctype=doctype or self.info.doctype, pretty_print=pretty_print
        )
764463
def from_string(cls, jss, xml_string):
        
        root = ElementTree.fromstring(xml_string.encode('utf-8'))
        return cls(jss, root)
153854
def to_xml_string(str = '')
      validate_attributes_for_chart_type
      str << '<c:dLbls>'
      %w(d_lbl_pos show_legend_key show_val show_cat_name show_ser_name show_percent show_bubble_size show_leader_lines).each do |key|
        next unless instance_values.keys.include?(key) && instance_values[key] != nil
        str <<  "<c:#{Axlsx::camel(key, false)} val='#{instance_values[key]}' />" 
      end
      str << '</c:dLbls>'
    end
72378
def tree_to_html(tree):
    """"""
    ul = etree.Element('ul')
    html_listify([tree], ul)
    return HTML_WRAPPER.format(etree.tostring(ul))
219857
private StringTreeNode buildOrgHierarchyTree(final Object[] data) {
		StringTreeNode childNode = new StringTreeNode((String) data[0]);

		if (data.length > 1) {
			for (int i = 1; i < data.length; i++) {
				childNode.add(buildOrgHierarchyTree((Object[]) data[i]));
			}
		}

		return childNode;
	}
417244
def paula_etree_to_string(tree, dtd_filename):
    """"""
    return etree.tostring(
        tree, pretty_print=True, xml_declaration=True,
        encoding="UTF-8", standalone='no',
        doctype='<!DOCTYPE paula SYSTEM "{0}">'.format(dtd_filename))
503193
def node_to_elem(root):
    
    def generate_elem(append, node, level):
        var = "e" + str(level)
        arg = repr(node.tag)
        if node.attrib:
            arg += ", **%r" % node.attrib
        if level == 1:
            append("e1 = Element(%s)" % arg)
        else:
            append("%s = SubElement(e%d, %s)" % (var, level - 1, arg))
        if not node.nodes:
            append("%s.text = %r" % (var, node.text))
        for x in node:
            generate_elem(append, x, level + 1)
    # generate code to create a tree
    output = []
    generate_elem(output.append, root, 1)  # print "\n".join(output)
    namespace = {"Element": ElementTree.Element,
                 "SubElement": ElementTree.SubElement}
    exec("\n".join(output), globals(), namespace)
    return namespace["e1"]
988656
def to_xml_string(str = '')
      str << '<?xml version="1.0" encoding="UTF-8"?>'
      str << ('<pivotTableDefinition xmlns="' << XML_NS << '" name="' << name << '" cacheId="' << cache_definition.cache_id.to_s << '"  dataOnRows="1" applyNumberFormats="0" applyBorderFormats="0" applyFontFormats="0" applyPatternFormats="0" applyAlignmentFormats="0" applyWidthHeightFormats="1" dataCaption="Data" showMultipleLabel="0" showMemberPropertyTips="0" useAutoFormatting="1" indent="0" compact="0" compactData="0" gridDropZones="1" multipleFieldFilters="0">')
      str << ('<location firstDataCol="1" firstDataRow="1" firstHeaderRow="1" ref="' << ref << '"/>')
      str << ('<pivotFields count="' << header_cells_count.to_s << '">')
      header_cell_values.each do |cell_value|
        str << pivot_field_for(cell_value, !no_subtotals_on_headers.include?(cell_value))
      end
      str << '</pivotFields>'
      if rows.empty?
        str << '<rowFields count="1"><field x="-2"/></rowFields>'
        str << '<rowItems count="2"><i><x/></i> <i i="1"><x v="1"/></i></rowItems>'
      else
        str << ('<rowFields count="' << rows.size.to_s << '">')
        rows.each do |row_value|
          str << ('<field x="' << header_index_of(row_value).to_s << '"/>')
        end
        str << '</rowFields>'
        str << ('<rowItems count="' << rows.size.to_s << '">')
        rows.size.times do |i|
          str << '<i/>'
        end
        str << '</rowItems>'
      end
      if columns.empty?
        str << '<colItems count="1"><i/></colItems>'
      else
        str << ('<colFields count="' << columns.size.to_s << '">')
        columns.each do |column_value|
          str << ('<field x="' << header_index_of(column_value).to_s << '"/>')
        end
        str << '</colFields>'
      end
      unless pages.empty?
        str << ('<pageFields count="' << pages.size.to_s << '">')
        pages.each do |page_value|
          str << ('<pageField fld="' << header_index_of(page_value).to_s << '"/>')
        end
        str << '</pageFields>'
      end
      unless data.empty?
        str << "<dataFields count=\"#{data.size}\">"
        data.each do |datum_value|
          # The correct name prefix in ["Sum","Average", etc...]
          str << "<dataField name='#{(datum_value[:subtotal]||'')} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'"
          str << " subtotal='#{datum_value[:subtotal]}' " if datum_value[:subtotal]
          str << "/>"
        end
        str << '</dataFields>'
      end
      # custom pivot table style
      unless style_info.empty?
        str << '<pivotTableStyleInfo'
        style_info.each do |k,v|
          str << ' ' << k.to_s << '="' << v.to_s << '"'
        end
        str << ' />'
      end
      str << '</pivotTableDefinition>'
    end