php - getting attributes in simplexml_load_string -
below function using convert xml array $xml = '<xml><codeshareinfo operatingcarrier="ey" operatingflightnumber="269">etihad airways</codeshareinfo></xml>'; $obj = simplexml_load_string($xml); // parse xml $obj->registerxpathnamespace("soap", "http://www.w3.org/2003/05/soap-envelope"); $array = json_decode(json_encode($obj), true); // convert array when try parent node "xml" <xml><codeshareinfo operatingcarrier="ey" operatingflightnumber="269">etihad airways</codeshareinfo></xml> i result array ( [codeshareinfo] => etihad airways ) but if try without parent node "xml" <codeshareinfo operatingcarrier="ey" operatingflightnumber="269">etihad airways</codeshareinfo> i can attributes , value array ( [@attributes] => array ( [operatingcarrier] =>...