Unknown data in the XML file

e0qjcistopl

New Member
I'm trying to write data from mysql to XML file through PHP, but I got unknown data in the file. I got this output:\[code\]1 1 1 1 1 1 1 1 1 W W W W W W W W W a a a a a a a a a s s s s s s s s s n n n n n n n n n g g g g g g g g g a a a a a a a a a M M M M M M M M M C C C C C C C C C C C C C C C C C C 3 3 3 3 3 3 3 3 3 W W W W W W W W W C C C C C C C C C C C C C C C C C C J J J J J J J J J P P P P P P P P P C C C C C C C C C M M M M M M M M M C C C C C C C C C C C C C C C C C C 4 4 4 4 4 4 4 4 4 h h h h h h h h h y y y y y y y y y n n n n n n n n n m m m m m m m m m h h h h h h h h h h h h h h h h h h M M M M M M M M M C C C C C C C C C C C C C C C C C C 5 5 5 5 5 5 5 5 5 h h h h h h h h h y y y y y y y y y n n n n n n n n n m m m m m m m m m h h h h h h h h h h h h h h h h h h M M M M M M M M M C C C C C C C C C C C C C C C C C C 6 6 6 6 6 6 6 6 6 w w w w w w w w w l l l l l l l l l i i i i i i i i i s s s s s s s s s Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y M M M M M M M M M C C C C C C C C C C C C C C C C C C\[/code\]Can you help me?After multiple runs it doesnt create the file at all.\[code\] $sql = mysql_query("SELECT * FROM question_bank "); $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement( "Exams" ); $doc->appendChild( $r ); while($row = mysql_fetch_assoc($sql)) { foreach( $row as $Exams => $Exam ) { $b = $doc->createElement( "Exam" ); $E_No = $doc->createElement( "E_No" ); $E_No->appendChild( $doc->createTextNode( $Exam['E_No'] ) ); $b->appendChild( $E_No ); $C_ID = $doc->createElement( "C_ID" ); $C_ID->appendChild( $doc->createTextNode( $Exam['C_ID'] ) ); $b->appendChild( $C_ID ); $Question = $doc->createElement( "Question" ); $Question->appendChild( $doc->createTextNode( $Exam['Question'] ) ); $b->appendChild( $Question ); $Choise_1 = $doc->createElement( "Choise_1" ); $Choise_1->appendChild( $doc->createTextNode( $Exam['Choise_1'] ) ); $b->appendChild( $Choise_1 ); $Choise_2 = $doc->createElement( "Choise_2" ); $Choise_2->appendChild( $doc->createTextNode( $Exam['Choise_2'] ) ); $b->appendChild( $Choise_2 ); $Choise_3 = $doc->createElement( "Choise_3" ); $Choise_3->appendChild( $doc->createTextNode( $Exam['Choise_3'] ) ); $b->appendChild( $Choise_3 ); $Choise_4 = $doc->createElement( "Choise_4" ); $Choise_4->appendChild( $doc->createTextNode( $Exam['Choise_4'] ) ); $b->appendChild( $Choise_4 ); $Correct_Answer = $doc->createElement( "Correct_Answer" ); $Correct_Answer->appendChild( $doc->createTextNode( $Exam['Correct_Answer'] ) ); $b->appendChild( $Correct_Answer ); $Question_Type = $doc->createElement( "Question_Type" ); $Question_Type->appendChild( $doc->createTextNode( $Exam['Question_Type'] ) ); $b->appendChild( $Question_Type ); $r->appendChild( $b ); } } echo $doc->saveXML(); $doc->save("wte.xml"); \[/code\]
 
Back
Top