src/XML/Element.php
public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
	{
		$child		= NULL;
		if( $nsPrefix )
		{
			$namespaces	= $this->getDocNamespaces();
			$key		= $nsPrefix ? $nsPrefix.':'.$name : $name;
			if( array_key_exists( $nsPrefix, $namespaces ) )
				$child	= parent::addChild( $name, NULL, $namespaces[$nsPrefix] );
			else if( $nsURI )
				$child	= parent::addChild( $key, NULL, $nsURI );
			else
				throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
		}
		else
			$child	= parent::addChild( $name );
		if( $value !== NULL )
			$child->setValue( $value );
		return $child;
	}
public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
	{
		$child		= NULL;
		if( $nsPrefix )
		{
			$namespaces	= $this->getDocNamespaces();
			$key		= $nsPrefix ? $nsPrefix.':'.$name : $name;
			if( array_key_exists( $nsPrefix, $namespaces ) )
				$child	= parent::addChild( $name, NULL, $namespaces[$nsPrefix] );
			else if( $nsURI )
				$child	= parent::addChild( $key, NULL, $nsURI );
			else
				throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
		}
		else
			$child	= parent::addChild( $name );
		if( $value !== NULL )
			$child->setValue( $value );
		return $child;
	}
public function addChild ( $ name , $ value = NULL , $ nsPrefix = NULL , $ nsURI = NULL ) { $ child = NULL ; if ( $ nsPrefix ) { $ namespaces = $ this -> getDocNamespaces ( ) ; $ key = $ nsPrefix ? $ nsPrefix . ':' . $ name : $ name ; if ( array_key_exists ( $ nsPrefix , $ namespaces ) ) $ child = parent :: addChild ( $ name , NULL , $ namespaces [ $ nsPrefix ] ) ; else if ( $ nsURI ) $ child = parent :: addChild ( $ key , NULL , $ nsURI ) ; else throw new RuntimeException ( 'Namespace prefix is not registered and namespace URI is missing' ) ; } else $ child = parent :: addChild ( $ name ) ; if ( $ value !== NULL ) $ child -> setValue ( $ value ) ; return $ child ; }
Adds a child element. Sets node content as CDATA section if necessary.
@access		public
@param		string		$name		Name of child element
@param		string		$value		Value of child element
@param		string		$nsPrefix	Namespace prefix of child element
@param		string		$nsURI		Namespace URI of child element
@return		XML_Element
@throws		RuntimeException		if namespace prefix is neither registered nor given
Adds a child element . Sets node content as CDATA section if necessary .