src/XML/DOM/ObjectSerializer.php
protected static function serializeVarsRec( $array, &$node )
	{
		foreach( $array as $key => $value)
		{
			switch( gettype( $value ) )
			{
				case 'NULL':
					$child	= new XML_DOM_Node( "null" );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'boolean':
					$child	= new XML_DOM_Node( "boolean", (int) $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'string':
					$child	= new XML_DOM_Node( "string", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'integer':
					$child	= new XML_DOM_Node( "integer", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'double':
					$child	= new XML_DOM_Node( "double", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'array':
					$child	= new XML_DOM_Node( "array" );
					$child->setAttribute( "name", $key );
					self::serializeVarsRec( $value, $child );
					$node->addChild( $child );
					break;
				case 'object':
					$child	= new XML_DOM_Node( "object" );
					$child->setAttribute( "name", $key );
					$child->setAttribute( "class", get_class( $value ) );
					$vars	= get_object_vars( $value );
					self::serializeVarsRec( $vars, $child );
					$node->addChild( $child );
					break;
			}
		}
	}
protected static function serializeVarsRec( $array, &$node )
	{
		foreach( $array as $key => $value)
		{
			switch( gettype( $value ) )
			{
				case 'NULL':
					$child	= new XML_DOM_Node( "null" );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'boolean':
					$child	= new XML_DOM_Node( "boolean", (int) $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'string':
					$child	= new XML_DOM_Node( "string", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'integer':
					$child	= new XML_DOM_Node( "integer", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'double':
					$child	= new XML_DOM_Node( "double", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'array':
					$child	= new XML_DOM_Node( "array" );
					$child->setAttribute( "name", $key );
					self::serializeVarsRec( $value, $child );
					$node->addChild( $child );
					break;
				case 'object':
					$child	= new XML_DOM_Node( "object" );
					$child->setAttribute( "name", $key );
					$child->setAttribute( "class", get_class( $value ) );
					$vars	= get_object_vars( $value );
					self::serializeVarsRec( $vars, $child );
					$node->addChild( $child );
					break;
			}
		}
	}
protected static function serializeVarsRec ( $ array , & $ node ) { foreach ( $ array as $ key => $ value ) { switch ( gettype ( $ value ) ) { case 'NULL' : $ child = new XML_DOM_Node ( "null" ) ; $ child -> setAttribute ( "name" , $ key ) ; $ node -> addChild ( $ child ) ; break ; case 'boolean' : $ child = new XML_DOM_Node ( "boolean" , ( int ) $ value ) ; $ child -> setAttribute ( "name" , $ key ) ; $ node -> addChild ( $ child ) ; break ; case 'string' : $ child = new XML_DOM_Node ( "string" , $ value ) ; $ child -> setAttribute ( "name" , $ key ) ; $ node -> addChild ( $ child ) ; break ; case 'integer' : $ child = new XML_DOM_Node ( "integer" , $ value ) ; $ child -> setAttribute ( "name" , $ key ) ; $ node -> addChild ( $ child ) ; break ; case 'double' : $ child = new XML_DOM_Node ( "double" , $ value ) ; $ child -> setAttribute ( "name" , $ key ) ; $ node -> addChild ( $ child ) ; break ; case 'array' : $ child = new XML_DOM_Node ( "array" ) ; $ child -> setAttribute ( "name" , $ key ) ; self :: serializeVarsRec ( $ value , $ child ) ; $ node -> addChild ( $ child ) ; break ; case 'object' : $ child = new XML_DOM_Node ( "object" ) ; $ child -> setAttribute ( "name" , $ key ) ; $ child -> setAttribute ( "class" , get_class ( $ value ) ) ; $ vars = get_object_vars ( $ value ) ; self :: serializeVarsRec ( $ vars , $ child ) ; $ node -> addChild ( $ child ) ; break ; } } }
Adds XML Nodes to a XML Tree by their Type while supporting nested Arrays.
@access		protected
@static
@param		array			$array		Array of Vars to add
@param		XML_DOM_Node	$node		current XML Tree Node
@return		string
Adds XML Nodes to a XML Tree by their Type while supporting nested Arrays .