public static function xmlToArray($xml) {
	  // check passed data
    if(!is_string($xml)) {
	    // bad data possed
      throw new LinkedInException('LinkedIn->xmlToArray(): bad data passed, $xml must be a non-zero length string.');
	  }
	  
	  $parser = xml_parser_create();
	  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    if(xml_parse_into_struct($parser, $xml, $tags)) {
	    $elements = array();
      $stack    = array();
      foreach($tags as $tag) {
        $index = count($elements);
        if($tag['type'] == 'complete' || $tag['type'] == 'open') {
          $elements[$tag['tag']]               = array();
          $elements[$tag['tag']]['attributes'] = (array_key_exists('attributes', $tag)) ? $tag['attributes'] : NULL;
          $elements[$tag['tag']]['content']    = (array_key_exists('value', $tag)) ? $tag['value'] : NULL;
          if($tag['type'] == 'open') {
            $elements[$tag['tag']]['children'] = array();
            $stack[count($stack)] = &$elements;
            $elements = &$elements[$tag['tag']]['children'];
          }
        }
        if($tag['type'] == 'close') {
          $elements = &$stack[count($stack) - 1];
          unset($stack[count($stack) - 1]);
        }
      }
      $return_data = $elements;
	  } else {
	    // not valid xml data
	    $return_data = FALSE;
	  }
	  xml_parser_free($parser);
    return $return_data;
  }
public static function xmlToArray($xml) {
	  // check passed data
    if(!is_string($xml)) {
	    // bad data possed
      throw new LinkedInException('LinkedIn->xmlToArray(): bad data passed, $xml must be a non-zero length string.');
	  }
	  
	  $parser = xml_parser_create();
	  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    if(xml_parse_into_struct($parser, $xml, $tags)) {
	    $elements = array();
      $stack    = array();
      foreach($tags as $tag) {
        $index = count($elements);
        if($tag['type'] == 'complete' || $tag['type'] == 'open') {
          $elements[$tag['tag']]               = array();
          $elements[$tag['tag']]['attributes'] = (array_key_exists('attributes', $tag)) ? $tag['attributes'] : NULL;
          $elements[$tag['tag']]['content']    = (array_key_exists('value', $tag)) ? $tag['value'] : NULL;
          if($tag['type'] == 'open') {
            $elements[$tag['tag']]['children'] = array();
            $stack[count($stack)] = &$elements;
            $elements = &$elements[$tag['tag']]['children'];
          }
        }
        if($tag['type'] == 'close') {
          $elements = &$stack[count($stack) - 1];
          unset($stack[count($stack) - 1]);
        }
      }
      $return_data = $elements;
	  } else {
	    // not valid xml data
	    $return_data = FALSE;
	  }
	  xml_parser_free($parser);
    return $return_data;
  }
public static function xmlToArray ( $ xml ) { // check passed data if ( ! is_string ( $ xml ) ) { // bad data possed throw new LinkedInException ( 'LinkedIn->xmlToArray(): bad data passed, $xml must be a non-zero length string.' ) ; } $ parser = xml_parser_create ( ) ; xml_parser_set_option ( $ parser , XML_OPTION_CASE_FOLDING , 0 ) ; xml_parser_set_option ( $ parser , XML_OPTION_SKIP_WHITE , 1 ) ; if ( xml_parse_into_struct ( $ parser , $ xml , $ tags ) ) { $ elements = array ( ) ; $ stack = array ( ) ; foreach ( $ tags as $ tag ) { $ index = count ( $ elements ) ; if ( $ tag [ 'type' ] == 'complete' || $ tag [ 'type' ] == 'open' ) { $ elements [ $ tag [ 'tag' ] ] = array ( ) ; $ elements [ $ tag [ 'tag' ] ] [ 'attributes' ] = ( array_key_exists ( 'attributes' , $ tag ) ) ? $ tag [ 'attributes' ] : NULL ; $ elements [ $ tag [ 'tag' ] ] [ 'content' ] = ( array_key_exists ( 'value' , $ tag ) ) ? $ tag [ 'value' ] : NULL ; if ( $ tag [ 'type' ] == 'open' ) { $ elements [ $ tag [ 'tag' ] ] [ 'children' ] = array ( ) ; $ stack [ count ( $ stack ) ] = & $ elements ; $ elements = & $ elements [ $ tag [ 'tag' ] ] [ 'children' ] ; } } if ( $ tag [ 'type' ] == 'close' ) { $ elements = & $ stack [ count ( $ stack ) - 1 ] ; unset ( $ stack [ count ( $ stack ) - 1 ] ) ; } } $ return_data = $ elements ; } else { // not valid xml data $ return_data = FALSE ; } xml_parser_free ( $ parser ) ; return $ return_data ; }
Converts passed XML data to an array.

@param str $xml
The XML to convert to an array.

@return arr
Array containing the XML data.
@return bool
FALSE if passed data cannot be parsed to an array.
Converts passed XML data to an array .