php - Unable to get attributes when using SimpleXML -
i unable attributes. simple xml:
<comments> <id auto="5" hallo="1234567">id</id> <comment hybrid="1">comment</comment> <type> <name surname="0">type</name> <label> <case_0>in</case_0> <case_1>out</case_1> </label> </type> </comments>
and php code:
$xml = simplexml_load_file($filepath); foreach ($xml->children() $children) { $attributes = $children->attributes(); print_r($attributes->hallo); }
the output should 1234567... printed output null. missing here because methods getname() , getvalue() works fine.
thanks!
in above code correct. , working fine me.this output
simplexmlelement object ( [0] => 1234567 ).
there might issue in loading file . check file path correct result.
Comments
Post a Comment