/** * @param ExSimpleXmlElement $xml_node * @param bool $use_attr_param * @return array|string */ private function _getNodeAttrs($xml_node, $use_attr_param = true) { $attrs = array(); if ($use_attr_param) { foreach ($xml_node->attributes() as $attr => $value) { $attrs[$attr] = (string) $value; } } else { if ($xml_node->exCount() > 0) { foreach ($xml_node->children() as $child_node) { if ($child_node->exCount() > 0) { $attrs[$child_node->getName()] = $this->_getNodeAttrs($child_node, false); } else { $attrs[$child_node->getName()] = (string) $child_node; } } } else { $attrs = (string) $xml_node; } if (is_array($attrs) && empty($attrs)) { $attrs = ''; } } return $attrs; }