Serialize a text node.
170193
function serializeText (node, opts) {
  return encode(node.nodeValue, extend({
    named: true,
    special: { '<': true, '>': true, '&': true }
  }, opts));
}
849140
def serialize_for_reading(element):
    
    xml = etree.tostring(element, encoding='unicode', pretty_print=True)
    return XmlString(xml)
302502
def get_text_from_node(self, node, regex=None, group=1):
        """"""
        text = self._get_stripped_text_from_node(node)

        if regex is not None:
            text = self._filter_by_regex(regex, text, group)

        return text
650538
private String toText(AstNode node) throws IOException {
    StringBuilder out = new StringBuilder();
    if (node instanceof StringContentNode) {
      out.append(((StringContentNode)node).getContent());
    } else if (node instanceof ContentNode) {
      NodeList nodes = ((ContentNode) node).getContent();
      for (AstNode subNode : nodes) {
        out.append(toText(subNode));
      }
    }
    return out.toString();
  }
1191561
public static String serializeNoNS(Node node) {
        StringBuffer buf = new StringBuffer();
        buf.append("<");
        buf.append(node.getLocalName());
        for (Entry<QName, String> entry : getAttributes(node).entrySet()) {
            QName name = entry.getKey();
            if (name.getNamespaceURI() != null) {
                buf.append(" ");
                buf.append(name.getLocalPart());
                buf.append("=\"");
                buf.append(entry.getValue());
                buf.append("\"");
            }
        }
        boolean tagOpen = true;
        NodeList children = node.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node n = children.item(i);
            short type = node.getNodeType();
            if (type == Node.TEXT_NODE) {
                if (tagOpen) {
                    buf.append(">\n");
                    tagOpen = false;
                }
                buf.append(node.getTextContent());
            } else if (type == Node.ELEMENT_NODE) {
                if (tagOpen) {
                    buf.append(">\n");
                    tagOpen = false;
                }
                buf.append(serializeNoNS(n));
                buf.append("\n");
            }
        }
        if (tagOpen) {
            buf.append("/>\n");
        } else {
            buf.append("</");
            buf.append(node.getLocalName());
            buf.append(">\n");
        }
        return buf.toString();
        // ByteArrayOutputStream baos = new ByteArrayOutputStream();
        // try {
        // TransformerFactory factory = TransformerFactory.newInstance();
        // File f = Misc.getResourceAsFile("com/occamlab/te/drop-ns.xsl");
        // Transformer transformer = factory.newTransformer(new
        // StreamSource(f));
        //
        // DOMSource src = new DOMSource(node);
        // StreamResult dest = new StreamResult(baos);
        // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
        // "yes");
        // transformer.transform(src, dest);
        // } catch (Exception e) {
        // System.out.println("Error serializing node.  "+e.getMessage());
        // }
        //
        // return baos.toString();
    }
788704
def serialize_array(self, tag):
        """"""
        elements = self.comma.join(f'{el}{tag.item_suffix}' for el in tag)
        return f'[{tag.array_prefix}{self.semicolon}{elements}]'
1081437
function processTextNode(node, options) {
    options = options || {};

    var data = [].concat(getBasicFields(node, options)).
        concat([
            node.lineCount
        ]);

    if (!options.body) {
        data = data.concat(getExtensionFields(node, options));
    }

    data.node = node;
    return data;
}
1056445
def serialize(expr):
    """"""

    result = None

    if isinstance(expr, string_types):
        result = expr

    elif expr is not None:
        result = '=py:{0}'.format(expr)

    return result
898494
def text_to_data(self, text, elt, ps):
        '''
        '''
        prefix,localName = SplitQName(text)
        nsdict = ps.GetElementNSdict(elt)
        prefix = prefix or ''
        try:
            namespaceURI = nsdict[prefix]
        except KeyError, ex:
            raise EvaluateException('cannot resolve prefix(%s)'%prefix,
                ps.Backtrace(elt))
                
        v = (namespaceURI,localName)
        if self.pyclass is not None:
            return self.pyclass(v)    
        return v
1161531
def node_stat_copy(self, node_or_char, node=None):
        """"""
        if node is None:
            node = node_or_char
        else:
            node = self._real.character[node_or_char].node[node]
        return {
            k: v.unwrap() if hasattr(v, 'unwrap') and not hasattr(v, 'no_unwrap') else v
            for (k, v) in node.items() if k not in {
                'character',
                'name',
                'arrival_time',
                'next_arrival_time'
            }
        }
1371797
function serializeDoctype (node) {
  var r = '<!DOCTYPE ' + node.name;

  if (node.publicId) {
    r += ' PUBLIC "' + node.publicId + '"';
  }

  if (!node.publicId && node.systemId) {
    r += ' SYSTEM';
  }

  if (node.systemId) {
    r += ' "' + node.systemId + '"';
  }

  r += '>';
  return r;
}
4604
def _create_text_node(self, root, name, value, cdata=False):
        '''
        
        '''
        if is_empty_or_none(value):
            return

        if type(value) == date:
            value = date_to_string(value)

        if type(value) == datetime:
            value = datetime_to_string(value)

        if isinstance(value, Decimal):
            value = "0" if not value else str(value)

        tag = root.ownerDocument.createElement(name)
        value = value.decode('utf-8')
        if cdata:
            tag.appendChild(root.ownerDocument.createCDATASection(value))
        else:
            tag.appendChild(root.ownerDocument.createTextNode(value))

        return root.appendChild(tag)
1366488
def process_text(self, kind, context):
		""""""
		
		result = None
		
		while True:
			chunk = yield None
			
			if chunk is None:
				if result:
					yield result.clone(line=repr(result.line))
				
				return
			
			if not result:
				result = chunk
				continue
			
			result.line += chunk.line
1182938
def _do_text(self, node):
        ''''''
        if not _in_subset(self.subset, node): return
        s = string.replace(node.data, "&", "&amp;")
        s = string.replace(s, "<", "&lt;")
        s = string.replace(s, ">", "&gt;")
        s = string.replace(s, "\015", "&#xD;")
        if s: self.write(s)
787945
def get_text_node(self, tree, xpath_str):
        """"""
        try:
            text = tree.xpath(xpath_str, namespaces=self.namespaces)[0].text
            return text_type(text) if text else ''
        except IndexError:  # pragma: nocover
            return ''
397840
def serialize(self, node):
        """"""
        if isinstance(node.tag, types.FunctionType):
            # this looks like a bug of ElementTree: comments are stored as
            # functions!?? see https://hg.python.org/sandbox/python2.7/file/tip/Lib/xml/etree/ElementTree.py#l458
            return
        if self.nsmap is not None:
            tag = self.shorten(node.tag)
        else:
            tag = node.tag
        with warnings.catch_warnings():  # unwanted ElementTree warning
            warnings.simplefilter('ignore')
            leafnode = not node
        # NB: we cannot use len(node) to identify leafs since nodes containing
        # an iterator have no length. They are always True, even if empty :-(
        if leafnode and node.text is None:
            self.emptyElement(tag, node.attrib)
            return
        self.start_tag(tag, node.attrib)
        if node.text is not None:
            txt = escape(scientificformat(node.text).strip())
            if txt:
                self._write(txt)
        for subnode in node:
            self.serialize(subnode)
        self.end_tag(tag)
1072207
def xml(self, text=TEXT):
        
        def convert(line):
            xml = "  <item>\n"
            for f in line.index:
                xml += "    <field name=\"%s\">%s</field>\n" % (f, line[f])
            xml += "  </item>\n"
            return xml
        return "<items>\n" + '\n'.join(self._data.apply(convert, axis=1)) + \
               "</items>"