<?php
$qp = qp('<?xml version="1.0"? ><quiz><quizinfo/><resultSet/></quiz>', 'quizinfo')
->append('<authorName>' . $name . '</authorname>')
// repeat above for as many elements as you need.
->top() // Go back to the top of the document
->find('resultSet'); // Search for resultSet section
// For each item in the results (wherever you get them), add a result entry
foreach ($results as $result) {
$qp->branch()
->append('<result/>')
->find('result:last')
->append('<authorName>' . $result->author . '</resultName>')
// Do that for as many elements as you need
}
// Do this to write the output
$qp->writeXML();
?>