mariachi
0
Q:

convert xml file to array php

public function xmlToArray($xmlstring){
    
  $xml = simplexml_load_string($xmlstring, "SimpleXMLElement", LIBXML_NOCDATA);
  $json = json_encode($xml);
  $array = json_decode($json,TRUE);

  return $array;

}
1
$xmlfile = file_get_contents($path);
		$ob= simplexml_load_string($xmlfile);
		$json  = json_encode($ob);
		$configData = json_decode($json, true);
0

New to Communities?

Join the community