How can i get the value of attribute in of a xml node in php?
问题 I'm using simplexml to read a xml file. So far i'm unable to get the attribute value i'm looking for. this is my code. if(file_exists($xmlfile)){ $doc = new DOMDocument(); $doc->load($xmlfile); $usergroup = $doc->getElementsByTagName( "preset" ); foreach($usergroup as $group){ $pname = $group->getElementsByTagName( "name" ); $att = 'code'; $name = $pname->attributes()->$att; //not working $name = $pname->getAttribute('code'); //not working if($name==$preset_name){ echo($name); $group-