I am trying to work with XML like this sample:
<?xml version="1.0"?>
<quizReport version="1" xsi:schemaLocation="http://www.ispringsolutions.com/ispring/quizbuilder/quizresults quizReport.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ispringsolutions.com/ispring/quizbuilder/quizresults">
<quizSettings timeLimit="0" maxNormalizedScore="100" maxScore="20" quizType="graded">
<passingPercent>0.6</passingPercent>
</quizSettings>
<summary time="4" percent="0.5" score="10">
<variables>
<variable title="Nom" value="test1411" name="USER_NAME"/>
<variable title="Courriel" value="" name="USER_EMAIL"/>
</variables>
</summary>
<questions>
<trueFalseQuestion usedAttempts="1" awardedPoints="10" maxAttempts="1" maxPoints="10" status="correct" id="{11AD6662-ACF3-4C2B-A3E6-04311C0DD8DB}">
<direction>Le mot de passe de votre compte iNews est indépendant de votre mot de passe radiocanadien géré par ActiveDirectory. </direction>
<answers userAnswerIndex="0" correctAnswerIndex="0">
<answer>Vrai </answer>
<answer>Faux </answer>
</answers>
</trueFalseQuestion>
<trueFalseQuestion usedAttempts="1" awardedPoints="0" maxAttempts="1" maxPoints="10" status="incorrect" id="{F13CF7F1-C830-41AF-A54C-CE78EE383611}">
<direction>Le protocole FTP permet de reprendre un transfert de fichier qui a été arrêté, sans recommencer le transfert depuis le début. </direction>
<answers userAnswerIndex="1" correctAnswerIndex="0">
<answer>Vrai </answer>
<answer>Faux </answer>
</answers>
</trueFalseQuestion>
</questions>
</quizReport>
Each question has an ID attribute, e.g. {11AD6662-ACF3-4C2B-A3E6-04311C0DD8DB}. The status of the question is returned as text (i.e. correct or incorrect).
My goal is to extract each question status and put in a database where a column is labelled with the same question ID (I'm comfortable with MySQL INSERT).
I've tried many solutions (xPath, foreach...) and I can't get any piece of code to work. All my efforts were made with SimpleXMLElement.
So, at the end, I will insert the value correct or incorrect into the DB under a column labelled with question id (e.g. {11AD6662-ACF3-4C2B-A3E6-04311C0DD8DB}) for every single question of the XML (which can contain up to 100 questions). So some sort of loop through the XML is needed.
I must point out that the tag name truFalseQuestion may change according to the type of question (another question could be multipleChoiceQuestion for instance). I made this simple XML to help me understand on a step by step basis.