Create a child node at `parent` with the tag :attr:`tag`. Set the text
        contents to the value of the attribute which this descriptor represents
        at `instance`.

        If the value is :data:`None`, no element is generated.
439060
def to_sax(self, instance, dest):
        

        value = self.__get__(instance, type(instance))
        if value == self.default:
            return

        if self.declare_prefix is not False and self.tag[0]:
            dest.startPrefixMapping(self.declare_prefix, self.tag[0])
        dest.startElementNS(self.tag, None, {})
        try:
            dest.characters(self.type_.format(value))
        finally:
            dest.endElementNS(self.tag, None)
            if self.declare_prefix is not False and self.tag[0]:
                dest.endPrefixMapping(self.declare_prefix)
269919
def h(tagName, *children, **kwargs):
    
    attrs = {}
    if 'attrs' in kwargs:
        attrs = kwargs.pop('attrs')

    attrs = attrs.copy()
    attrs.update(kwargs)

    el = createComponent(tagName)
    return el(children, **attrs)
227861
def node(parent, indent = nil)
      return unless (name = lookahead(:node_lookahead) ||
                            lookahead(:shorthand_lookahead))

      # Skip node if it's a reserved keyword
      return nil if KEYWORDS.include? name[0].to_sym

      # Accept either explicit node_name or implicit :div node_name
      # with shorthand attributes
      if (node_name = accept :node)
        node_name = node_name.to_sym
        shorthand = shorthand_attributes
      elsif (shorthand = shorthand_attributes)
        node_name = :div
      end

      # Node creation options
      options = {}

      # Get leading whitespace
      options[:recursive] = accept(:recursive)

      # Get leading whitespace
      options[:leading_whitespace] = accept_stripped(:leading_whitespace)

      # Get trailing whitespace
      options[:trailing_whitespace] = accept_stripped(:trailing_whitespace)

      # Get wrapped node attributes
      atts = attributes(shorthand) || {}

      # Inherit attributes from definition
      options[:extension] = extend_attributes

      # Get unwrapped node attributes
      options[:attributes] = attributes_assignments atts, false

      # Create node
      current_node = [:node, node_name, options, [], indent]

      # Check for self enclosing tags and definitions
      def_check = !@definitions.keys.include?(node_name) &&
                  Settings::SELF_ENCLOSING.include?(node_name)

      # Check if the node is explicitly self enclosing
      if (close = accept_stripped :self_enclosing) || def_check
        current_node[@options][:self_enclosing] = true

        unless close.nil? || close.strip.empty?
          undo close
          Logger.error :parse, @code, @i, @j, :self_enclosing
        end
      end

      # Check whether we have explicit inline elements and add them
      # with increased base indentation
      if accept :inline_child
        # Inline node element
        Logger.error :parse,
                     @code,
                     @i,
                     @j,
                     :inline_child unless node current_node, indent
      elsif comment current_node, indent
        # Accept same line comments
      else
        # Accept inline text element
        text current_node, indent, false
      end

      # Add the current node to the root
      root current_node, indent

      # Add the parsed node to the parent
      parent[@children] << current_node
    end
291318
function setAttr(node, name, val, asProp, initial) {
	var el = node.el;

	if (node.ns != null)
		{ el.setAttribute(name, val); }
	else if (name === "class")
		{ el.className = val; }
	else if (name === "id" || typeof val === "boolean" || asProp)
		{ el[name] = val; }
	else if (name[0] === ".")
		{ el[name.substr(1)] = val; }
	else
		{ el.setAttribute(name, val); }
}
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)
671532
def set_child(self, i, child):
        
        child.parent = self
        self.children[i].parent = None
        self.children[i] = child
        self.changed()
15072
private static Element handleNode(Element parent, String xpathName) {

        // if node is no attribute, create a new node
        String childrenPart = null;
        String nodeName;
        int pos = xpathName.indexOf("[");
        if (pos > 0) {
            childrenPart = xpathName.substring(pos + 1, xpathName.length() - 1);
            nodeName = xpathName.substring(0, pos);
        } else {
            nodeName = xpathName;
        }
        // create node
        Element elem = parent.addElement(nodeName);
        if (childrenPart != null) {
            pos = childrenPart.indexOf("[");
            if ((pos > 0) && (childrenPart.indexOf("]") > pos)) {
                handleNode(elem, childrenPart);
                return elem;
            }
            if (childrenPart.contains("=")) {
                Map<String, String> children = CmsStringUtil.splitAsMap(childrenPart, "][", "=");
                // handle child nodes
                for (Map.Entry<String, String> child : children.entrySet()) {
                    String childName = child.getKey();
                    String childValue = child.getValue();
                    if (childValue.startsWith("'")) {
                        childValue = childValue.substring(1);
                    }
                    if (childValue.endsWith("'")) {
                        childValue = childValue.substring(0, childValue.length() - 1);
                    }
                    if (childName.startsWith("@")) {
                        elem.addAttribute(childName.substring(1), childValue);
                    } else if (childName.equals("text()")) {
                        elem.setText(childValue);
                    } else if (!childName.contains("(")) {
                        Element childElem = elem.addElement(childName);
                        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(childValue)) {
                            childElem.addText(childValue);
                        }
                    }
                }
            }
        }
        return elem;
    }
853268
function createNode(el, attr) {
	// html comment is not currently supported by virtual-dom
	if (el.nodeType === 3) {
		return createVirtualTextNode(el);

	// cdata or doctype is not currently supported by virtual-dom
	} else if (el.nodeType === 1 || el.nodeType === 9) {
		return createVirtualDomNode(el, attr);
	}

	// default to empty text node
	return new VText('');
}
282266
def _child(element, child_tagname):
    
    xpath = './%s' % child_tagname
    matching_children = element.xpath(xpath, namespaces=nsmap)
    return matching_children[0] if len(matching_children) else None
580451
def add_tag_before(tag_name, tag_text, parent_tag, before_tag_name):
    
    new_tag = Element(tag_name)
    new_tag.text = tag_text
    if get_first_element_index(parent_tag, before_tag_name):
        parent_tag.insert( get_first_element_index(parent_tag, before_tag_name) - 1, new_tag)
    return parent_tag
1086154
def create_node(doc, node_name, content=nil) #:doc:
      node = Nokogiri::XML::Node.new(node_name, doc)
      node.content = content if content
      node
    end
539475
function createElement (
	  tag,
	  data,
	  children
	) {
	  if (data && (Array.isArray(data) || typeof data !== 'object')) {
	    children = data;
	    data = undefined;
	  }
	  // make sure to use real instance instead of proxy as context
	  return _createElement(this._self, tag, data, children)
	}
1253555
public function createElement($tag, $attributes = null)
    {
        $node = parent::createElement($tag);
        $text = false;
        if (is_string($attributes)) {
            $node->setAttribute('class', $attributes);
        } else {
            if (is_array($attributes)) {
                foreach ($attributes as $key => $value) {
                    if ($key == 'text') {
                        $node->appendChild($this->createTextNode($value));
                        $text = true;
                    } else {
                        if (!is_null($value)) {
                            $node->setAttribute($key, $value);
                        }
                    }
                }
            }
        }
        if (!$text && !in_array($tag, ['img', 'br', 'input'])) {
            $node->appendChild($this->createTextNode(''));
        }
        return $node;
    }
739424
def assign(self, node):
        
        child = self.translate(node.child)
        attributes = ''
        if node.attributes:
            attributes = '({})'.format(','.join(node.attributes.names))
        return '[.${name}{attributes}$ {child} ]'\
            .format(name=node.name, attributes=attributes, child=child)
1199723
def node(node, indent)
      # Pretty print
      if @settings[:pretty]
        indentation = ' ' * indent
        inline = Settings::INLINE_NODE.include? node[@value]

        indentate = proc do
          if @in_definition
            buffer "' ' * (indent + #{indent})"
          else
            buffer_freeze indentation
          end
        end

        if inline
          inline_last_sibling = @sibling_stack[-1][-1] ? Settings::INLINE_NODE.include?(@sibling_stack[-1][-1][1]) : true

          if @sibling_stack[-1][-1] && @sibling_stack[-1][-1][0] == :plain
            buffer_remove_trailing_newline
          end

          if @in_definition || @sibling_stack[-1].length == 1 || !inline_last_sibling
            indentate[]
          end
        else
          indentate[]
        end

        @sibling_stack[-1] << [node[@type], node[@value]]
        @sibling_stack << [[node[@type], node[@value]]]
      end

      # Add the tag opening, with leading whitespace to the code buffer
      buffer_freeze ' ' if node[@options][:leading_whitespace]
      buffer_freeze "<#{node[@value]}"

      # Evaluate node extension in the current context
      if node[@options][:extension]
        extension_name = buffer_set_variable :extension,
                                             node[@options][:extension][@value]

        extension = {
          name: extension_name,
          escaped: node[@options][:extension][@options][:escaped]
        }
      end

      # Evaluate and generate node attributes, then process each one to
      # by generating the required attribute code
      buffer_attributes node[@options][:attributes],
                        extension


      # Check if the current node is self enclosing. Self enclosing nodes
      # do not have any child elements
      if node[@options][:self_enclosing]
        # If the tag is self enclosing, it cannot have any child elements.
        buffer_freeze '>'

        # Pretty print
        buffer_freeze "\n" if @settings[:pretty]

        # If we mistakenly add children to self enclosing nodes,
        # process each child element as if it was correctly indented
        # node[@children].each do |child|
        #   root child, indent + @settings[:indent]
        # end
      else
        # Set tag ending code
        buffer_freeze '>'

        # Pretty print
        if @settings[:pretty]
          if node[@children].length > 0
            buffer_freeze "\n" unless inline
          end
          # @sibling_stack << [[node[@type], node[@value]]]
        end

        # Process each child element recursively, increasing indentation
        node[@children].each do |child|
          root child, indent + @settings[:indent]
        end

        inline_last_child = @sibling_stack[-1][-2] &&
                            (@sibling_stack[-1][-2][0] == :plain ||
                              Settings::INLINE_NODE.include?(@sibling_stack[-1][-2][1]))

        # Pretty print
        if @settings[:pretty]
          if node[@children].length > 1 && inline_last_child
            buffer_freeze "\n"
          end

          if node[@children].size > 0 && !inline
            indentate[]
          end
        end

        # Set tag closing code
        buffer_freeze "</#{node[@value]}>"
        buffer_freeze ' ' if node[@options][:trailing_whitespace]

        # Pretty print
        if @settings[:pretty]
          buffer_freeze "\n" if !inline || @in_definition
        end
      end

      if @settings[:pretty]
        @sibling_stack.pop
      end
    end
254582
def add_node(node, parent):
    '''
    '''
    newNode = dict(node_id=node.id, children=[])
    parent["children"].append(newNode)
    if node.left: add_node(node.left, newNode)
    if node.right: add_node(node.right, newNode)
568191
def dom2object(node):
    

    value = []
    textnode_encountered = None
    for n in node.childNodes:

        if n.nodeType == 3:
            # Child is a text element - omit the dom tag #text and
            # go straight to the text value.

            # Note - only the last text value will be recorded

            msg = 'Text element has child nodes - this shouldn\'t happen'
            verify(len(n.childNodes) == 0, msg)


            x = n.nodeValue.strip()
            if len(x) == 0:
                # Skip empty text children
                continue

            textnode_encountered = value = x
        else:
            # XML element


            if textnode_encountered is not None:
                msg = 'A text node was followed by a non-text tag. This is not allowed.\n'
                msg += 'Offending text node: "%s" ' %str(textnode_encountered)
                msg += 'was followed by node named: "<%s>"' %str(n.nodeName)
                raise Exception, msg


            value.append(dom2object(n))


    # Deal with empty elements
    if len(value) == 0: value = ''


    if node.nodeType == 9:
        # Root node (document)
        tag = None
    else:
        # Normal XML node
        tag = node.nodeName


    X = XML_element(tag=tag,
                    value=value)

    return X