Write an element with the given name, content and attributes. If
 there is no content and no block is given, a self-closing element is
 created. Provide an empty string as content to create an empty,
 non-self-closing element.
12502
def element!(name, content = nil, attributes = nil)
      build! do
        if content or block_given?
          @_crafted << "<#{name}#{Tools.format_attributes(attributes)}>"
          if block_given?
            value = yield
            content = value if !@_appended or value.kind_of? String
          end
          content = content.to_s
          @_crafted << Tools.escape(content) if content != ""
          @_crafted << "</#{name}>"
        else
          @_crafted << "<#{name}#{Tools.format_attributes(attributes)}/>"
        end
      end
    end
486145
function writeTag(name, attrs, close, content) {
  var end = close ? '/>' : '>'
    , pairs = []
    , tag;

  for (var key in attrs) {
    pairs.push(key + '="' + escape(attrs[key]) + '"');
  }
  tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;

  if (content){
    tag += content + '</' + name + end;
  }
  return tag;
}
1151613
def emit_element( output_node, element_name, attr_hash=nil )
      if (attr_hash != nil) then
        attr_hash.each do |key, value|
          if (value == nil) then
            attr_hash.delete( key )
          end
        end
        if attr_hash.empty? then
          attr_hash = nil
        end
      end
      output_node.add_element( element_name, attr_hash )
    end
18341
public void writeProperty(String name, String value) {
        writeElement(name, OPENING);
        _buffer.append(value);
        writeElement(name, CLOSING);
    }
794147
function () {
    var text = '[' + this.tag

    _.each(this.attrs.numeric, function (value) {
      if (/\s/.test(value)) {
        text += ' "' + value + '"'
      } else {
        text += ' ' + value
      }
    })

    _.each(this.attrs.named, function (value, name) {
      text += ' ' + name + '="' + value + '"'
    })

    // If the tag is marked as `single` or `self-closing`, close the
    // tag and ignore any additional content.
    if (this.type === 'single') {
      return text + ']'
    } else if (this.type === 'self-closing') {
      return text + ' /]'
    }

    // Complete the opening tag.
    text += ']'

    if (this.content) {
      text += this.content
    }

    // Add the closing tag.
    return text + '[/' + this.tag + ']'
  }
586470
@Override
    public void writeAttribute(String localName, String value)
        throws IOException, XMLStreamException
    {
        writeAscii(BYTE_SPACE);
        writeName(localName);
        writeAscii(BYTE_EQ, BYTE_QUOT);

        int len = value.length();
        if (len > 0) {
            if (mAttrValueWriter != null) { // custom escaping?
                mAttrValueWriter.write(value, 0, len);
            } else { // nope, default
                writeAttrValue(value);
            }
        }
        writeAscii(BYTE_QUOT);
    }
625445
public void createEmptyElements(final ZipUTF8Writer writer) throws IOException {
        this.logger.log(Level.FINER, "Writing empty ods elements to zip file");
        for (final String elementName : EMPTY_ELEMENT_NAMES) {
            this.logger.log(Level.FINEST, "Writing odselement: {0} to zip file", elementName);
            writer.putNextEntry(new ZipEntry(elementName));
            writer.closeEntry();
        }
    }
489019
@Override
    public void writeAttribute(String nsURI, String localName, String value)
        throws XMLStreamException
    {
        // No need to set mAnyOutput, nor close the element
        if (!mStartElementOpen) {
            throwOutputError(ErrorConsts.WERR_ATTR_NO_ELEM);
        }
        doWriteAttr(localName, nsURI,
		    findOrCreateAttrPrefix(null, nsURI, mCurrElem),
                    value);
    }
1156209
function createElement(node, document) {
	var tag = void 0;
	if ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) !== 'object') {
		// we have a text node, so create one
		tag = document.createTextNode('' + node);
	} else {
		tag = document.createElement(node.tagName);
		// add all required attributes
		Object.keys(node.attributes).forEach(function (attr) {
			tag.setAttribute(attr, node.attributes[attr].value);
		});
		// define it's inner structure
		tag.innerHTML = getInnerHTML(node);
		tag.__hash = node.__hash;
		attachSetAttribute(tag);
	}

	return tag;
}
1255067
function tag(name, attrs, close, content) {
  var end = close ? '/>' : '>';
  var pairs = [];
  var tag;

  for (var key in attrs) {
    if (Object.prototype.hasOwnProperty.call(attrs, key)) {
      pairs.push(key + '="' + escape(attrs[key]) + '"');
    }
  }

  tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
  if (content) {
    tag += content + '</' + name + end;
  }
  return tag;
}
774610
@Override
    public void writeAttribute(String nsURI, String localName, String value)
        throws XMLStreamException
    {
        // No need to set mAnyOutput, nor close the element
        if (!mStartElementOpen) {
            throwOutputError(ErrorConsts.WERR_ATTR_NO_ELEM);
        }
        String prefix = mCurrElem.getExplicitPrefix(nsURI);
        if (!mReturnNullForDefaultNamespace && prefix == null) {
            throwOutputError("Unbound namespace URI '" + nsURI + "'");
        }
        doWriteAttr(localName, nsURI, prefix, value);
    }
626292
void writeStartElement(final Writer output, final String name, final Attributes atts) throws SAXException {
        try {
            output.write(LESS_THAN);
            output.write(name);
            for (int i = 0; i < atts.getLength(); i++) {
                output.write(STRING_BLANK);
                output.write(atts.getQName(i));
                output.write(EQUAL);
                output.write(QUOTATION);
                output.write(escapeXML(atts.getValue(i)));
                output.write(QUOTATION);
            }
            output.write(GREATER_THAN);
        } catch (IOException e) {
            throw new SAXException(e);
        }
    }
747914
def write(self, content):
        ''''''
        self.buffer.write(content)
        if settings.DEBUG:
            self.buffer.write('\n')
233406
def _create_element(name, element_type, data, server=None):
    '''
    
    '''
    # Define property and id from name and properties + remove SaltStack parameters
    if 'properties' in data:
        data['property'] = ''
        for key, value in data['properties'].items():
            if not data['property']:
                data['property'] += '{0}={1}'.format(key, value.replace(':', '\\:'))
            else:
                data['property'] += ':{0}={1}'.format(key, value.replace(':', '\\:'))
        del data['properties']

    # Send request
    _api_post(element_type, _clean_data(data), server)
    return unquote(name)
490900
public static void rewriteContent(@NotNull Element parent, @NotNull RewriteContentHandler rewriteContentHandler) {

    // iterate through content list and build new content list
    List<Content> originalContent = parent.getContent();
    List<Content> newContent = new ArrayList<Content>();
    for (Content contentElement : originalContent) {

      // handle element
      if (contentElement instanceof Element) {
        Element element = (Element)contentElement;

        // check if rewrite is needed for element
        List<Content> rewriteContent = rewriteContentHandler.rewriteElement(element);
        if (rewriteContent != null) {
          // element was removed
          if (rewriteContent.isEmpty()) {
            // do not add to newContent
          }

          // element is the same - rewrite child elements
          else if (rewriteContent.size() == 1 && rewriteContent.get(0) == element) { //NOPMD
            rewriteContent(element, rewriteContentHandler);
            newContent.add(element);
          }

          // element was replaced with other content - rewrite and add instead
          else {
            for (Content newContentItem : rewriteContent) {
              if (newContentItem instanceof Element) {
                Element newElement = (Element)newContentItem;
                rewriteContent(newElement, rewriteContentHandler);
              }
              newContent.add(newContentItem.clone());
            }
          }
        }

        // nothing to rewrite - do nothing, but rewrite child element
        else {
          rewriteContent(element, rewriteContentHandler);
          newContent.add(element);
        }

      }

      // handle text node
      else if (contentElement instanceof Text) {
        Text text = (Text)contentElement;

        // check if rewrite is needed for text node
        List<Content> rewriteContent = rewriteContentHandler.rewriteText(text);
        if (rewriteContent != null) {
          // element was removed
          if (rewriteContent.isEmpty()) {
            // do not add to newContent
          }

          // element is the same - ignore
          else if (rewriteContent.size() == 1 && rewriteContent.get(0) == text) { //NOPMD
            // add original element
            newContent.add(text);
          }

          // element was replaced with other content - add instead
          else {
            for (Content newContentItem : rewriteContent) {
              newContent.add(newContentItem.clone());
            }
          }
        }

        // nothing to rewrite - do nothing, but add original text element
        else {
          newContent.add(text);
        }

      }

      // unknown element - just add to new content
      else {
        newContent.add(contentElement);
      }

    }

    // replace original content with new content
    parent.removeContent();
    parent.addContent(newContent);

  }
1100768
public void writeAttribute(String name, Object value)
  {
    if (!_isElementOpen)
      throw new IllegalStateException("no open element");

    if (value == null)
      return;

    _isElementOpen = false;
    try {
      _strategy.writeAttribute(this, name, value);
    }
    finally {
      _isElementOpen = true;
    }

  }
147688
function(content) {
        var node = this.createElementNSPlus("atom:content", {
            attributes: {
                type: content.type || null
            }
        });
        if (content.src) {
            node.setAttribute("src", content.src);
        } else {
            if (content.type == "text" || content.type == null) {
                node.appendChild(
                    this.createTextNode(content.value)
                );
            } else if (content.type == "html") {
                if (typeof content.value != "string") {
                    throw "HTML content must be in form of an escaped string";
                }
                node.appendChild(
                    this.createTextNode(content.value)
                );
            } else if (content.type == "xhtml") {
                node.appendChild(content.value);
            } else if (content.type == "xhtml" ||
                           content.type.match(/(\+|\/)xml$/)) {
                node.appendChild(content.value);
            }
            else { // MUST be a valid Base64 encoding
                node.appendChild(
                    this.createTextNode(content.value)
                );
            }
        }
        return node;
    }