protected function xml($key = null, $default = null)
    {
        if (empty($this->contentAsArray)) {
            $content = $this->getContent();
            $data = DataFormatter::xmlToArray($content);

            if (!empty($data)) {
                if ((1 === count($data)) && !array_key_exists(ResourcesWrapper::getWrapper(), $data)) {
                    // All XML comes wrapped in a single wrapper, if not resource wrapper, remove it
                    $data = reset($data);
                }

                $this->contentAsArray = $data;
            }
        }

        if (null === $key) {
            return $this->contentAsArray;
        } else {
            return array_get($this->contentAsArray, $key, $default);
        }
    }
protected function xml($key = null, $default = null)
    {
        if (empty($this->contentAsArray)) {
            $content = $this->getContent();
            $data = DataFormatter::xmlToArray($content);

            if (!empty($data)) {
                if ((1 === count($data)) && !array_key_exists(ResourcesWrapper::getWrapper(), $data)) {
                    // All XML comes wrapped in a single wrapper, if not resource wrapper, remove it
                    $data = reset($data);
                }

                $this->contentAsArray = $data;
            }
        }

        if (null === $key) {
            return $this->contentAsArray;
        } else {
            return array_get($this->contentAsArray, $key, $default);
        }
    }
protected function xml ( $ key = null , $ default = null ) { if ( empty ( $ this -> contentAsArray ) ) { $ content = $ this -> getContent ( ) ; $ data = DataFormatter :: xmlToArray ( $ content ) ; if ( ! empty ( $ data ) ) { if ( ( 1 === count ( $ data ) ) && ! array_key_exists ( ResourcesWrapper :: getWrapper ( ) , $ data ) ) { // All XML comes wrapped in a single wrapper, if not resource wrapper, remove it $ data = reset ( $ data ) ; } $ this -> contentAsArray = $ data ; } } if ( null === $ key ) { return $ this -> contentAsArray ; } else { return array_get ( $ this -> contentAsArray , $ key , $ default ) ; } }
Returns XML payload data.

@param null $key
@param null $default

@return array|mixed|null
Returns XML payload data .