Returns an Array Structure from XML String.
@access		public
@return		array
518558
public function toArray( $xml )
	{
		$this->data	= array();
		$this->xml	= xml_parser_create();
		xml_set_object( $this->xml, $this );
		xml_set_element_handler( $this->xml, 'handleTagOpenForArray', 'handleTagCloseForArray' );
		xml_set_character_data_handler( $this->xml, 'handleCDataForArray' );
		$this->last	= array( &$this->data );
		if( !xml_parse( $this->xml, $xml ) )
		{
			$msg	= "XML error: %s at line %d";
			$error	= xml_error_string( xml_get_error_code( $this->xml ) );
			$line	= xml_get_current_line_number( $this->xml );
			throw new RuntimeException( sprintf( $msg, $error, $line ) );
		}
		xml_parser_free( $this->xml );
		return $this->data;
	}
269671
public function toArray()
	{
		return [
			'name' => SerializationHelper::stringOrNull($this->name),
			'desc' => SerializationHelper::stringOrNull($this->description),
			'author' => SerializationHelper::serialize($this->author),
			'copyright' => SerializationHelper::serialize($this->copyright),
			'links' => SerializationHelper::serialize($this->links),
			'time' => DateTimeHelper::formatDateTime($this->time),
			'keywords' => SerializationHelper::stringOrNull($this->keywords),
			'bounds' => SerializationHelper::serialize($this->bounds),
			'extensions' => SerializationHelper::serialize($this->extensions)
		];
	}
488023
public function toString()
    {
        $addChildren = function($value, $key, $node)
        {
            if (is_scalar($value))
            {
                $n = $node->addChild('option', $value);
                $n->addAttribute('name', $key);
                $n->addAttribute('type', gettype($value));
            }
            else
            {
                $n = $node->addChild('config');
                $n->addAttribute('name', $key);
                $n->addAttribute('type', gettype($value));

                array_walk($value, $addChildren, $n);
            }
        };

        $xml  = simplexml_load_string('<config />');
        $data = $this->toArray();
        array_walk($data, $addChildren, $xml);

        return $xml->asXML();
    }
1186665
function toArray()
    {
        $out = array ();

        $attributes = $this->attribute( 'attributes' );
        if ( count( $attributes ) )
        {
            $out['attributes'] = $attributes;
        }

        $children = $this->attribute( 'children' );
        foreach( $children as $name => $value )
        {
            if ( is_object( $value ) )
            {
                $out['children'][$name] = $value->toArray();
            }
            else if ( is_array( $value ) )
            {
                foreach( $value as $key => $val )
                {
                    if ( is_object( $val ) )
                    {
                        $value[$key] = $val->toArray();
                    }
                }
                $out['children'][$name] = $value;
            }
            else
            {
                $out['children'][$name] = $value;
            }
        }

        if ( !count( $children ) )
        {
            $textContent = $this->attribute( 'textContent' );
            if ( $textContent != '' )
            {
                $out['textContent'] = $textContent;
            }
        }

        return $out;
    }
588938
public function toArray()
    {
        $array = [
            'title' => $this->getName(),
            'label' => $this->getLabel(),
            'icon' => $this->getIcon(),
            'action' => $this->getAction(),
            'mainRoute' => $this->getMainRoute(),
            'event' => $this->getEvent(),
            'eventArguments' => $this->getEventArguments(),
            'hasSettings' => $this->getHasSettings(),
            'disabled' => $this->getDisabled(),
            'id' => (null != $this->getId()) ? $this->getId() : str_replace('.', '', uniqid('', true)), //FIXME don't use uniqid()
        ];

        if (count($this->getChildRoutes()) > 0) {
            $array['childRoutes'] = $this->getChildRoutes();
        }

        if (null != $this->getHeaderIcon() || null != $this->getHeaderTitle()) {
            $array['header'] = [
                'title' => $this->getHeaderTitle(),
                'logo' => $this->getHeaderIcon(),
            ];
        }

        $children = $this->getChildren();

        usort(
            $children,
            function(NavigationItem $a, NavigationItem $b) {
                $aPosition = $a->getPosition() ?: PHP_INT_MAX;
                $bPosition = $b->getPosition() ?: PHP_INT_MAX;

                return $aPosition - $bPosition;
            }
        );

        foreach ($children as $key => $child) {
            /* @var NavigationItem $child */
            $array['items'][$key] = $child->toArray();
        }

        return $array;
    }
1046213
function xmlString( )
    {
        $doc = new DOMDocument( '1.0', 'utf-8' );

        $root = $doc->createElement( "ezoption" );
        $doc->appendChild( $root );

        $name = $doc->createElement( "name" );
        $name->appendChild( $doc->createCDATASection( $this->Name ) );
        $root->appendChild( $name );

        $options = $doc->createElement( "options" );
        $root->appendChild( $options );

        foreach ( $this->Options as $option )
        {
            $optionNode = $doc->createElement( "option" );
            $optionNode->appendChild( $doc->createCDATASection( $option["value"] ) );
            $optionNode->setAttribute( "id", $option['id'] );
            $optionNode->setAttribute( 'additional_price', $option['additional_price'] );
            $options->appendChild( $optionNode );
        }

        $xml = $doc->saveXML();

        return $xml;
    }
68779
public function toArray() : array
    {
        $result = [];

        if (!empty($this->id)) {
            $result['id'] = $this->id;
        }

        if (!empty($this->link)) {
            $result['links']['about'] = $this->link;
        }

        if (!empty($this->status)) {
            $result['status'] = "{$this->status}";
        }

        if (!empty($this->code)) {
            $result['code'] = "{$this->code}";
        }

        if (!empty($this->title)) {
            $result['title'] = $this->title;
        }

        if (!empty($this->detail)) {
            $result['detail'] = $this->detail;
        }

        if (!empty($this->source)) {
            $result['source'] = $this->source->map(function ($item) {
                return $item;
            });
        }

        if (!empty($this->meta)) {
            $result['meta'] = $this->meta;
        }

        if (!empty($this->exception)) {
            $e = $this->exception;
            if ($e instanceof ExtendedLoggingInformation) {
                $result['exception'] = $e->context();
            } else {
                $result['exception'] = [
                    'exception' => get_class($e),
                    'message' => $e->getMessage(),
                    'stacktrace' => $e->getTrace(),
                ];
            }
        }

        return $result;
    }
769472
protected function convertXmlToArray($xml)
    {
        if (is_string($xml)) {
            $xml = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
        }
        $result = (array) $xml;
        foreach ($result as $key => $value) {
            if (!is_scalar($value)) {
                $result[$key] = $this->convertXmlToArray($value);
            }
        }
        return $result;
    }
1132034
public function __toArray()
    {
        $result = [];
        if ($this->status !== null) {
            $result['status'] = $this->status;
        }
        if ($this->code !== null) {
            $result['code'] = $this->code;
        }
        if ($this->title !== null) {
            $result['title'] = $this->title;
        }
        return $result;
    }
906320
public function toArray()
	{
		$list = parent::toArray();

		$list['attribute.domain'] = $this->getDomain();
		$list['attribute.code'] = $this->getCode();
		$list['attribute.status'] = $this->getStatus();
		$list['attribute.typeid'] = $this->getTypeId();
		$list['attribute.type'] = $this->getType();
		$list['attribute.position'] = $this->getPosition();
		$list['attribute.label'] = $this->getLabel();

		return $list;
	}
405538
public function toArray(): array
    {
        $groups = [];

        foreach ($this->groups as $group) {
            $key = Key::sanitize($group['name']);

            $key = sprintf('%s_%s', $this->parentKey, $key);

            $group = [
                'field' => sprintf('field_%s', Key::hash($key)),
                'operator' => $group['operator'],
                'value' => $group['value'],
            ];

            $groups[] = $group;
        }

        return $groups;
    }
1273253
public function fromXml(string $xml): array
    {
        if (!$this->isEmptyValue($xml)) {

            libxml_use_internal_errors(true);

            // convert string to xml object
            $result = simplexml_load_string("$xml", 'SimpleXMLElement', LIBXML_NOCDATA);

            if ($result) {
                return $this->fromClass($result);

            } else {

                foreach (libxml_get_errors() as $error) {

                    // if don`t have container add that`s
                    if ($error->code == 5) {
                        $this->errors = [];

                        // append container and parse again
                        return $this->fromXml("<DATA>$xml</DATA>");

                    } else
                        $this->setError($error->code, $error->message);
                }
            }
        }

        return $this->result;
    }
856004
public function toArray()
	{
		$result = [];
		
		foreach (get_class_methods($this) as $method)
		{
			if (stripos($method, 'get') === 0)
			{
				$result[strtolower(substr($method, 3))] = $this->{$method}();
			}
		}
		
		return $result;
	}
228974
public function loadXMLStructure() {
        if ($this->fileExists()) {
            // Let's validate the XML file
            if (!$this->validateXMLStructure()) {
                return false;
            }
            $contents = file_get_contents($this->path);
            if (strpos($contents, '<STATEMENTS>')) {
                //delete the removed STATEMENTS section, it would not validate
                $contents = preg_replace('|<STATEMENTS>.*</STATEMENTS>|s', '', $contents);
                debugging('STATEMENTS section is not supported any more, please use db/install.php or db/log.php');
            }
            // File exists, so let's process it
            // Load everything to a big array
            $xmlarr = xmlize($contents);
            // Convert array to xmldb structure
            $this->xmldb_structure = $this->arr2xmldb_structure($xmlarr);
            // Analyze results
            if ($this->xmldb_structure->isLoaded()) {
                $this->loaded = true;
                return true;
            } else {
                return false;
            }
        }
        return true;
    }
606838
protected static function recursiveXMLToArray($xml)
    {
        $x = null;
        if ($xml instanceof SimpleXMLElement) {
            $attributes = $xml->attributes();
            foreach ($attributes as $k => $v) {
                if ($v) {
                    $a[$k] = (string) $v;
                }
            }
            $x = $xml;
            $xml = get_object_vars($xml);
        }
        if (is_array($xml)) {
            if (count($xml) === 0) {
                return (string)$x;
            } // for CDATA
            $r = [];
            foreach ($xml as $key => $value) {
                $r[$key] = self::recursiveXMLToArray($value);
            }
            // Attributes
            if (isset($a)) {
                $r['@'] = $a;
            }
            return $r;
        }

        return (string) $xml;
    }
899989
public function toArray()
    {
        $data = [
            'text' => $this->getText(),
        ];

        if($this->getTitle()) $data['title'] = $this->getTitle();
        if($this->getTitle()) $data['ok_text'] = $this->getOkText();
        if($this->getTitle()) $data['dismiss_text'] = $this->getDismissText();

        return $data;
    }
660217
public function getHeaderArray()
    {
        $headerArray = (count($this->headers) > 0 ? $this->headers : []);
        if ($this->isJson) {
            $headerArray[] = 'Accept: application/json';
        }
        if ($this->isXML) {
            $headerArray[] = 'Accept: text/xml';
        }
        if ($this->method == 'POST' && count($this->data) > 0 && $this->isJson) {
            $headerArray[] = 'Content-type: application/json';
        } elseif ($this->method == 'POST' && count($this->data) > 0 && $this->isXML) {
            $headerArray[] = 'Content-type: text/xml';
        } elseif ($this->method == 'POST' && count($this->data) > 0) {
            $headerArray[] = 'Content-type: application/x-www-form-urlencoded';
        }
        if (count($this->cookies) > 0) {
            $cookies = '';
            foreach ($this->cookies as $key => $value) {
                if (mb_strlen($cookies) > 0) {
                    $cookies .= '; ';
                }
                $cookies .= urlencode($key) . '=' . urlencode($value);
            }
            $headerArray[] = 'Cookie: ' . $cookies;
        }

        return $headerArray;
    }