3
Colleagues.
I have the following XML.
<gabarito>
<avaliacao tipo="Prova" codigo="01" segmento="Ensino Médio" serie="Pré-Vestibular" questoes="20">
<disciplina nome="Matemática">
<questao numero="1" alternativas="A,B,C,D,E">
<resposta>C</resposta>
</questao>
<questao numero="2" alternativas="A,B,C,D,E">
<resposta>D</resposta>
</questao>
<questao numero="3" alternativas="A,B,C,D,E">
<resposta>A</resposta>
</questao>
</disciplina>
<disciplina nome="Física">
<questao numero="1" alternativas="A,B,C,D,E">
<resposta>C</resposta>
</questao>
<questao numero="2" alternativas="A,B,C,D,E">
<resposta>D</resposta>
</questao>
<questao numero="3" alternativas="A,B,C,D,E">
<resposta>A</resposta>
</questao>
</disciplina>
</avaliacao>
</gabarito>
How would I get the answer? I’m doing it this way:
$xml = simplexml_load_file($arquivoXML);
foreach($xml as $notasGabarito){
$resXML = $xml->avaliacao->disciplina->questao->resposta;
echo "Res => " .$resXML."<br>";
}
}
Only he’s returning me only the first C.
Perfect Gabriel, it worked... now what if it’s in the case of feedback? I want to take the name of the disciplines, which are more than one, but I’m also not getting it. As I would in this case?
– user24136
@Jose.Marcos is very simple, makes a feedback Count, if you have 50 jigs, you make a match to the example above just iterating with the variable $i in it, giving a print to debug
– Gabriel Rodrigues
right... I did as you said, but returns only the name of the first discipline, IE, Mathematics... as I would also to catch Physics?
– user24136