@param SimpleXMLElement $xml

@return array
190606
private function getCommonMessageProperties (SimpleXMLElement $xml)
    {
        return [
            (string)$xml->FromUserName,
            (string)$xml->ToUserName,
            (string)$xml->MsgId,
            (int)$xml->CreateTime
        ];
    }
370658
protected function parseXml($xml)
    {
        $data = array();
        
        foreach ($xml->children() as $name => $child) {
            if (count($child->children()) > 0) {
                $value = $this->parseXml($child);
            } else {
                $value = (string) $child;
            }

            $node = array(
                'tag'   => $name,
                'value' => $value
            );

            foreach ($child->attributes() as $name => $value) {
                $node['attributes'][$name] = (string) $value[0];
            }
            
            $data[] = $node;
        }

        return $data;
    }
1192159
protected function _asArray(\SimpleXMLElement $element)
    {
        $output = $this->_asData($element);

        if (!$element->count()) {
            return $output;
        }

        return $this->_pushArray($output, $element);
    }
648234
private function simpleXmlToArray(\SimpleXMLElement $xmlObject): array
    {
        $array = [];
        foreach ($xmlObject->children() as $node) {
            $array[$node->getName()] = is_array($node) ? $this->simpleXmlToArray($node) : (string) $node;
        }

        return $array;
    }
797386
protected static function parseAtom(\SimpleXMLElement $xml)
    {
        if (!isset($xml->entry)) {
            return false;
        }

        $url = '';

        foreach ($xml->link as $link) {
            $attributes = $link->attributes();

            if (empty($attributes->href) || ((string) $attributes->rel === 'self')) {
                continue;
            }
            $url = (string) $attributes->href;
            break;
        }

        return [
            'url' => $url,
            'items' => self::getAtomEntries($xml->entry),
        ];
    }
407853
public function toArray(SimpleXMLElement $xml = null)
	{
		if ($xml === null) {
			$xml = $this->xml;
		}

		if (!$xml->children()) {
			return (string) $xml;
		}

		$arr = array();
		foreach ($xml->children() as $tag => $child) {
			if (count($xml->$tag) === 1) {
				$arr[$tag] = $this->toArray($child);
			} else {
				$arr[$tag][] = $this->toArray($child);
			}
		}

		return $arr;
	}
511604
protected function parseXML($xml){
        $this->list = array();
        if (!$xml){
            return false;
        }

        foreach ($xml->SubscriptionList->children() as $x) {
            $temp = array();
            $temp['NotificationType'] = (string)$x->NotificationType;
            $temp['IsEnabled'] = (string)$x->IsEnabled;
            $temp['Destination']['DeliveryChannel'] = (string)$x->Destination->DeliveryChannel;
            foreach ($x->Destination->AttributeList->children() as $z) {
                $temp['Destination']['AttributeList'][(string)$z->Key] = (string)$z->Value;
            }
            $this->list[] = $temp;
        }
    }
1357067
public static function toArray(string $xml): array
    {
        $backup = libxml_disable_entity_loader(true);
        $result = static::xml2Data(simplexml_load_string(
            $xml,
            'SimpleXMLElement',
            LIBXML_COMPACT | LIBXML_NOCDATA | LIBXML_NOBLANKS
        ));
        libxml_disable_entity_loader($backup);
        return $result;
    }
746409
private function _XML2Array($xml)
    {
        $envelope = simplexml_load_string($xml, "SimpleXMLElement", 0, 'http://schemas.xmlsoap.org/soap/envelope/');
        foreach ($envelope->Body as $response) {
            foreach ($response->children('http://Hps.Exchange.PosGateway') as $item) {
                return $item;
            }
        }
        return null;
    }
655415
protected function xmlToArray($xml)
    {
        // Do not output libxml error messages to screen
        $useErrors = libxml_use_internal_errors(true);
        $array = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
        libxml_use_internal_errors($useErrors);

        // Fix the issue that XML parse empty data to new SimpleXMLElement object
        return array_map('strval', (array) $array);
    }
1095898
protected function readAttributesArray(\SimpleXMLElement $element): array
    {
        $attributes = [];
        foreach ($element->attributes() as $attrName => $attr) {
            $attributes[(string)$attrName] = (string)$attr;
        }

        return $attributes;
    }
204894
public static function toXml($xml)
    {
        if ($xml instanceof XmlBuilder) {
            return $xml->getDom();
        }
        if ($xml instanceof \DOMDocument) {
            return $xml;
        }
        $dom = new \DOMDocument();
        $dom->preserveWhiteSpace = false;
        if ($xml instanceof \DOMNode) {
            $xml = $dom->importNode($xml, true);
            $dom->appendChild($xml);
            return $dom;
        }

        if (is_array($xml)) {
            return self::arrayToXml($dom, $dom, $xml);
        }
        if (!empty($xml)) {
            $dom->loadXML($xml);
        }
        return $dom;
    }
147204
private function loadProperty(\SimpleXMLElement $element)
    {
        $property = [];

        if (isset($element['alias'])) {
            $property['alias'] = (string) $element['alias'];
        }

        if (isset($element['type'])) {
            $property['type'] = (string) $element['type'];
        }

        if (isset($element['exclude'])) {
            $property['exclude'] = (string) $element['exclude'] === 'true';
        }

        if (isset($element['expose'])) {
            $property['expose'] = (string) $element['expose'] === 'true';
        }

        if (isset($element['accessor'])) {
            $property['accessor'] = (string) $element['accessor'];
        }

        if (isset($element['readable'])) {
            $property['readable'] = (string) $element['readable'] === 'true';
        }

        if (isset($element['writable'])) {
            $property['writable'] = (string) $element['writable'] === 'true';
        }

        if (isset($element['mutator'])) {
            $property['mutator'] = (string) $element['mutator'];
        }

        if (isset($element['since'])) {
            $property['since'] = (string) $element['since'];
        }

        if (isset($element['until'])) {
            $property['until'] = (string) $element['until'];
        }

        if (isset($element['max-depth'])) {
            $property['max_depth'] = (int) $element['max-depth'];
        }

        foreach ($element->group as $group) {
            $property['groups'][] = (string) $group;
        }

        if (isset($element['xml-attribute'])) {
            $property['xml_attribute'] = (string) $element['xml-attribute'] === 'true';
        }

        if (isset($element['xml-value'])) {
            $property['xml_value'] = (string) $element['xml-value'] === 'true';
        }

        if (isset($element['xml-inline'])) {
            $property['xml_inline'] = (string) $element['xml-inline'] === 'true';
        }

        if (isset($element['xml-entry'])) {
            $property['xml_entry'] = (string) $element['xml-entry'];
        }

        if (isset($element['xml-entry-attribute'])) {
            $property['xml_entry_attribute'] = (string) $element['xml-entry-attribute'];
        }

        if (isset($element['xml-key-as-attribute'])) {
            $property['xml_key_as_attribute'] = (string) $element['xml-key-as-attribute'] === 'true';
        }

        if (isset($element['xml-key-as-node'])) {
            $property['xml_key_as_node'] = (string) $element['xml-key-as-node'] === 'true';
        }

        return $property;
    }
854812
public static function toSimpleXMLElement($xml)
    {
        if ($xml instanceof \SimpleXMLElement) {
            return $xml;
        }

        if ($xml instanceof \DOMDocument) {
            return simplexml_import_dom($xml);
        }

        if (is_string($xml)) {

            if (is_file($xml)) {
                return simplexml_load_file($xml);
            }

            return simplexml_load_string($xml);
        }

        $type = is_object($xml) ? get_class($xml) : gettype($xml);

        throw new \InvalidArgumentException("Cannot convert instance of '$type' to DOMDocument");
    }
640898
protected function parseFeeDetail($xml){
        $r = array();
        $r['FeeType'] = (string)$xml->FeeType;
        $r['FeeAmount'] = $this->parseMoney($xml->FeeAmount);
        if (isset($xml->FeePromotion)){
            $r['FeePromotion'] = $this->parseMoney($xml->FeePromotion);
        }
        if (isset($xml->TaxAmount)){
            $r['TaxAmount'] = $this->parseMoney($xml->TaxAmount);
        }
        $r['FinalFee'] = $this->parseMoney($xml->FinalFee);
        if (isset($xml->IncludedFeeDetailList)){
            $r['IncludedFeeDetailList'] = array();
            foreach($xml->IncludedFeeDetailList->children() as $x){
                $r['IncludedFeeDetailList'][] = $this->parseFeeDetail($x);
            }
        }
        return $r;
    }
1053301
public static function xmlToArray($xml) {
        $arr = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
        return $arr;
    }
362578
private static function getXml(\SimpleXMLElement $element) {
        $getTest = $element->asXML();
        if ($getTest === false) {
            $getTest = '';
        }

        return $getTest;
    }