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

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo