Serialize given tag to XML

@param  string $tagName
@param  array  $attributes
@param  string $content
@return string
514218
protected function writeTag($tagName, array $attributes, $content)
	{
		$xml = '<' . $tagName;
		foreach ($attributes as $attrName => $attrValue)
		{
			$xml .= ' ' . $attrName . '="' . htmlspecialchars($attrValue) . '"';
		}
		if ($content === '')
		{
			$xml .= '/>';
		}
		else
		{
			$xml .= '>' . $content . '</' . $tagName . '>';
		}

		return $xml;
	}
1074583
public function tagNotpresent($tag, $content)
    {
        $name     = $tag['name'];
        $name     = $this->autoBuildVar($name);
        $parseStr = '<?php if(!isset(' . $name . ')): ?>' . $content . '<?php endif; ?>';

        return $parseStr;
    }
893704
public static function create( $name, $content = NULL, $attributes = array(), $data = array() )
	{
		if( !strlen( $name	= trim( $name ) ) )
			throw new InvalidArgumentException( 'Missing tag name' );
		$name		= strtolower( $name );
		try{
			$attributes	= self::renderAttributes( $attributes );
			$data		= self::renderData( $data );
		}
		catch( InvalidArgumentException $e ) {
			if( version_compare( PHP_VERSION, '5.3.0', '>=' ) )
				throw new RuntimeException( 'Invalid attributes', NULL, $e );						//  throw exception and transport inner exception
			throw new RuntimeException( 'Invalid attributes', NULL );								//  throw exception
		}
		if( $content === NULL || $content === FALSE )												//  no node content defined, not even an empty string
			if( !in_array( $name, self::$shortTagExcludes ) )										//  node name is allowed to be a short tag
				return "<".$name.$attributes.$data."/>";											//  build and return short tag
		if( is_array( $content ) )																	//  content is an array, may be nested
			$content	= self::flattenArray( $content, '' );
		if( is_numeric( $content ) )
			$content	= (string) $content;
		if( is_object( $content ) ){
			if( !method_exists( $content, '__toString' ) ){											//  content is not a renderable object
				$message	= 'Object of class "'.get_class( $content ).'" cannot be rendered';		//  prepare message about not renderable object
				throw new InvalidArgumentException( $message ); 									//  break with error message
			}
			$content	= (string) $content;														//  render object to string
		}
		if( !is_null( $content ) && !is_string( $content ) ){										//  content is neither NULL nor string so far
			$message	= 'Content type "'.gettype( $content ).'" is not supported';				//  prepare message about wrong content data type
			throw new InvalidArgumentException( $message ); 										//  break with error message
		}
		return "<".$name.$attributes.$data.">".$content."</".$name.">";								//  build and return full tag
	}
1241623
public static function progress(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("progress", $content, $attributes);
    }
749131
public static function add_attributes($tag, $attributes) {
        $tag = self::remove_attributes($tag, array_keys($attributes));
        if (!preg_match('/^(<.*?)(>.*)$/s', $tag, $matches)) {
            return $tag;
        }
        $rv = $matches[1];
        foreach ($attributes as $name => $value) {
            $rv .= " $name=\"".s($value).'"';
        }
        $rv .= $matches[2];
        return $rv;
    }
602774
public static function table(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("table", $content, $attributes);
    }
789142
public function tag($tag, $content, array $attributes = [])
    {
        return $this->htmlBuilder->tag($tag, $content, $attributes);
    }
1266742
public function printTag( $tag, $value, array $attributes = [] )
	{
		$attributes = $this->buildAttributesFor( $tag, $attributes );

		printf( '<%s>%s</%s>',
			rtrim( sprintf( '%s %s', $tag, $attributes )),
			$value,
			$tag
		);
	}
841975
public function create(string $tag = 'div', $value = null, array $attributes = []): Htmlable
    {
        if (\is_array($value)) {
            $attributes = $value;
            $value = null;
        }

        $content = '<'.$tag.$this->attributes($attributes).'>';

        if (! \is_null($value)) {
            $content .= $this->entities($value).'</'.$tag.'>';
        }

        return $this->toHtmlString($content);
    }
385937
function extract (xml, tagName, attributeName) {
  if (!Array.isArray(tagName)) {
    tagName = [tagName]
  }

  var found = null
  var tagFound = null
  for (var i = 0; i < tagName.length; i++) {
    // without attributes
    found = new RegExp(`<${tagName[i]}\\s*>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }

    // with attributes
    found = new RegExp(`<${tagName[i]} .*?>(.+?)</${tagName[i]}>`, 'i').exec(xml)
    if (found) {
      tagFound = tagName[i]
      break
    }
  }

  if (found && attributeName) {
    var attribute = new RegExp(`<${tagFound} .*?${attributeName}=\"(.+?)\".*?>`, 'i').exec(found[0])
    if (attribute) {
      return attribute[1]
    }
  }

  return found ? found[1] : null
}
575937
public static function span(
        string $content = null, 
        array $attributes = []
    ) : string 
    {
        return self::tag("span", $content, $attributes);
    }
254855
public function getChildNode($nodeName = "", $nodeAttributes = array())
    {
        // init
        $obj = null;
        $count = 0;

        // action
        foreach ($this->Nodes as $node) {
            if (gettype($node) == 'object'
                && get_class($node) == 'Com\PaulDevelop\Library\Modeling\Xml\Tag'
            ) {
                if ($node->Name == $nodeName) {
                    // if found child node with good name, check attributes as well
                    $allAttributesAreOK = true;
                    foreach ($nodeAttributes as $key => $value) {
                        if ($node[$key]->Value != $value) {
                            $allAttributesAreOK = false;
                            break;
                        }
                    }

                    if ($allAttributesAreOK == true) {
                        $count++;
                        if ($count > 1) {
                            throw new MultipleChildrenFoundException(
                                'Found multiple children with name "'.$nodeName.'".'
                            );
                        }
                        $obj = $node;
                    }
                }
            }
        }

        // return
        return $obj;
    }
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;
    }
987677
public static function create(string $tag, string $content = null, array $attributes = null,
        bool $selfClosing = false, bool $v5 = true): string
    {
        if ($attributes != null) {
            $tmp = [];
            foreach ($attributes as $name => $value) {
                if ($value === null) { // eg: ['a' => 1, 'b' => null, ...]
                    $tmp[] = $name;
                } elseif (is_int($name)) { // eg: ['a' => 1, 'b', ...]
                    $tmp[] = $value;
                } else { // eg: ['a' => 1, 'b' => 2, ...]
                    $tmp[] = sprintf('%s="%s"', $name, strtr((string) $value, ['"' => '&quot;']));
                }
            }
            $attributes = ' '. join(' ', $tmp);
        }

        return $selfClosing || in_array($tag, self::$selfClosingTags)
            ? sprintf('<%s%s%s>', $tag, $attributes, $v5 ? '' : ' /')
            : sprintf('<%s%s>%s</%s>', $tag, $attributes, $content, $tag);
    }
548594
function(tagName, attributes, content) {
      var el = document.createElement(tagName);
      if (attributes) {
        Parse.$(el).attr(attributes);
      }
      if (content) {
        Parse.$(el).html(content);
      }
      return el;
    }
1354038
public function decorateHtmlTag($tag, array $attributes)
	{
		if (! $tag instanceof HtmlTag) {
			return null;
		}

		foreach ($attributes as $name => $value) {
			$tag->setAttribute($name, $value);
		}

		return $tag;
	}
583703
public static function createTag($tag, $attributes, $content = null)
    {
        $tag = strtolower($tag);

        // Build list of arguments
        $preparedAttributes = '';
        foreach ($attributes as $attributeKey => $attributeValue) {
            // Only set non-empty strings (ensures strlen(0) > 0)
            if (strlen($attributeValue) > 0) {
                $preparedAttributes .= sprintf(
                    ' %s="%s"',
                    $attributeKey,
                    Convert::raw2att($attributeValue)
                );
            }
        }

        // Check void element type
        if (in_array($tag, static::config()->get('void_elements'))) {
            if ($content) {
                throw new InvalidArgumentException("Void element \"{$tag}\" cannot have content");
            }
            return "<{$tag}{$preparedAttributes} />";
        }

        // Closed tag type
        return "<{$tag}{$preparedAttributes}>{$content}</{$tag}>";
    }