diff --git a/import_cli.php b/import_cli.php index 7446c15..990558e 100644 --- a/import_cli.php +++ b/import_cli.php @@ -143,15 +143,17 @@ if (file_exists($questionfile)) { $questionsection = $questions->documentElement->getElementsByTagName("questions")->item(0); - foreach ($questionsection->getElementsByTagName("question") as $question) { - $questiontext = $question->getElementsByTagName("questiontext")->item(0); - $newquestiontext = strip_tags(html_entity_decode($questiontext->textContent)); - $questiontext->nodeValue = htmlentities($newquestiontext, ENT_XML1); + if ($questionsection) { + foreach ($questionsection->getElementsByTagName("question") as $question) { + $questiontext = $question->getElementsByTagName("questiontext")->item(0); + $newquestiontext = strip_tags(html_entity_decode($questiontext->textContent)); + $questiontext->nodeValue = htmlentities($newquestiontext, ENT_XML1); - foreach ($question->getElementsByTagName("answer") as $answer) { - $answertext = $answer->getElementsByTagName("answertext")->item(0); - $newanswertext = strip_tags(html_entity_decode($answertext->textContent)); - $answertext->nodeValue = htmlentities($newanswertext, ENT_XML1); + foreach ($question->getElementsByTagName("answer") as $answer) { + $answertext = $answer->getElementsByTagName("answertext")->item(0); + $newanswertext = strip_tags(html_entity_decode($answertext->textContent)); + $answertext->nodeValue = htmlentities($newanswertext, ENT_XML1); + } } }