php - Get node values and attributes as an array using xpath -
is there way attributes , values array. here have node
<vehicle wheels="four" color="red"/>
what need array like
$vehicle = array("wheels" => "four", "color" => "red");
you can using simplexmlelement
parsing.
$xml = '<vehicle wheels="four" color="red"/>'; $x = new simplexmlelement($xml); $array = current($x->attributes()); print_r($array);