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 -

PowerShell script ffmpeg -

objective c - Pick image and crop image became low quality iOS -