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); 

Popular posts from this blog

java - Cannot send AES encrypted messages of over 47 characters -

php - How to set default value of a select dynamically from database using smarty? -

telerik - Reformat image format in PDF -