私はphpとsimplexmlを使用しています。私の問題は「forで属性を追加すること」です。私のコードは次のとおりです。
for($i=1;$i<=$compteur;$i++)
{
$jeu->situation->question->choix->addChild('rep',"\n".$rep[$i]."\n");
$jeu->situation->question->choix->rep->addAttribute('val',$i);
}
結果:
<choix>
<rep val="1">
</rep>
<rep>
</rep>
</choix>
彼は最初に追加します!!!