Parsing Poor XML into to PHP
| From: | John Taylor-Johnston | Date: | Mon, 17 Sep 2007 05:16:52 +0000 |
| Subject: | Parsing Poor XML into to PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-262156@lists.php.net to get a copy of this message | ||
Pour examples of xml, but this is what I want to do. I have a quiz.
BASICALLY How do EXTRACT THE Contents and Values of these tags into strings and arrays I can work with.
Depending upon the students answer, compared to the criterion below, I need to calculate a value = x/1. The score could very well be rounded down to 1/1, but at least each student will get the feedback, if a particular piece of feedback applies to the, If not, it will not appear on their evaluation sheet.
I can pseudo cod ehtis in my head, but am wondering where to get started. Can someone help me take <Instructions</Instrudtions> into a string for example?
Then take <Criterion[0]> through nmax = [5] into two arrays: CriterionValue and CriterionComment, as well as <feedback> 0=5 and organised the into arrays.
The rest, I think I can do.
John
<Instructions>Take the sentence below and transform it into a Information Question.</Instructions>
<Question>Harry Potter went to Hogwarts School of Wizardry.</Question>
<Answer>Where did Harry Potter go? </Answer>
<Criterion name=Criterion[0] value="1">Where did Harry Potter go to school?<Criterion>
<Feedback>The answer was the exact answer we expected.)</Feedback>
<Criterion name=Criterion[1] value=".9">Where did Harry Potter go to school ?<Criterion>
<Feedback>There was a syntax error using the "?" question mark.)</Feedback>
<Criterion name=Criterion[2] value=".2">Where <Criterion>
<Feedback>The answer contained the correct Question word. $Criterion[2].</Feedback>
<Criterion name=Criterion[3] value=".2">Where did<Criterion>
<Feedback>The answer contained in $Criterion[3].</Feedback>
<Criterion name=Criterion[4] value=".2">Where did Harry<Criterion>
<Feedback>The answer contained in $Criterion[4].</Feedback>
<Criterion name=Criterion[5] value=".2">Where did Harry go<Criterion>
<Feedback>The answer contained in $Criterion[5].</Feedback>
Unforgivable stuff:
<Criterion name=Criterion[6] value="-.2>Hogwarts School of Wizardry<Criterion>
<Feedback>No need to include the complement in a question that requires a complement.</Feedback>
<Criterion name=Criterion[7] value="-.2>go at school<Criterion>
<Feedback>"Go to school" not "go at school"</Feedback>