1. simple xml file to create
| <?xml version="1.0" encoding="UTF-8" ?> |
| <quizzes> |
| <quiz question point="2"> |
| <quizzes>What is PHP?</quizzes> |
| <answers>PHP Hypertext Preprocessor</answers> |
| </quiz question> |
| <quiz question point="3"> |
| <quizzes>What does the i in mysqli?</quizzes> |
| <answers>Improved</answers> |
| </quiz question> |
| <quiz question point="2"> |
| <quizzes>What is SQL?</quizzes> |
| <answers>Database</answers> |
| </quiz question> |
| <quiz question point="4"> |
| <quizzes>What is the wildcard in Prepard Statement?</quizzes> |
| <answers>?</answers> |
| </quiz question> |
| <quizzes> |
2. simply - XML
| <?php |
| if (file_exists('ask.xml')) { |
| echo 'Data found'; |
| $xml = simplexml_load_file('ask.xml'); |
| for ($i = 0; $i < count($xml); $i++) { |
| echo 'Punkte: ' . $xml->quizfrage[$i] ['point'] . '<br />'; |
| echo 'Antwort: ' . $xml->quizfrage[$i] ['answer'] . '<br />'; |
| echo '<hr />; |
| } |
| $xml->quizfrage[0] ['point'] = 1000; |
| $newXML = $xml->asXML(); |
| echo 'new:<br />; |
| echo '<pre>'; |
| echo htmlspecialchars($neuesXML); |
| echo '</pre>'; |
| } else { |
| echo 'Could not load data.'; |
| } |
| ?> |