generate radiobuttonlist dynamically

I have a form that displays text, questions and multiple choice answers for those questions. Lets say there are 3 questions, and 3 possible answers per question. I want to use radiobutton lists to display the answers and allow users to select one, and just one per question. The text used for the questions an answers is pulled from an xml file, not a db. The amount of questions and answers in this xml file has to be able to change, and therefore my form should change with it. I’ve done the logic for this is a regular standalone php script but am struggling to figure out how to implement it in Yii without putting php logic in a view file, which I’d like to avoid. here’s the code from the basic php script (not yii), can anyone tell me how’d I’d go about implementing this in yii. Below the script is this xml file being used.

<?php

$file = ‘questions.xml’;

$xml = simplexml_load_file($file);

$number_of_questions = (string)$xml->question_count[0]->number;

$number_of_answers = (string)$xml->answers_per_question[0]->number;

//$xmls = (string)simplexml_load_string($xml);

//$xmlIterator = (string)new SimpleXMLIterator($xmls);

?>

<HTML>

<HEAD>

<TITLE>Blank HTML Page</TITLE>

</HEAD>

<body>

<form name="vote">

<?php

for($i=0;$i<$number_of_questions;$i++)

{

 &#036;question = &#036;xml-&gt;Questions[&#036;i]-&gt;Question;


 echo &quot;&lt;p&gt;&#036;question&lt;/p&gt;&quot;;





for(&#036;p=0;&#036;p&lt;&#036;number_of_answers;&#036;p++)


{


	&#036;answer = &#036;xml-&gt;Questions[&#036;i]-&gt;answer[&#036;p]-&gt;_text;


	echo &quot;&lt;input type='radio' name='group.&#036;i+1' value='&#036;xml-&gt;Questions[&#036;i]-&gt;answer[&#036;p]-&gt;weight' /&gt;&#036;answer&lt;br /&gt;&quot;;


}

}

?>

<?xml version="1.0"?>

<Patent_Guide>

<question_count>

&lt;number&gt;2&lt;/number&gt;   

</question_count>

<answers_per_question>

&lt;number&gt;3&lt;/number&gt;

</answers_per_question>

&lt;Questions&gt;


	&lt;Question&gt;Question one goes here&lt;/Question&gt;


	&lt;answer&gt;


		&lt;_text&gt;answer 1 text goes here.&lt;/_text&gt;


		&lt;weight&gt;10&lt;/weight&gt;


	&lt;/answer&gt;


	&lt;answer&gt;


		&lt;_text&gt;answer 2 text goes here&lt;/_text&gt;


		&lt;weight&gt;7&lt;/weight&gt;


	&lt;/answer&gt;


	&lt;answer&gt;


		&lt;_text&gt; answer 3 text goes here&lt;/_text&gt;


		&lt;weight&gt;4&lt;/weight&gt;


	&lt;/answer&gt;


&lt;/Questions&gt;


&lt;Questions&gt;


   &lt;Questions&gt;


	&lt;Question&gt;Question two goes here&lt;/Question&gt;


	&lt;answer&gt;


		&lt;_text&gt;answer 1 text goes here.&lt;/_text&gt;


		&lt;weight&gt;10&lt;/weight&gt;


	&lt;/answer&gt;


	&lt;answer&gt;


		&lt;_text&gt;answer 2 text goes here&lt;/_text&gt;


		&lt;weight&gt;7&lt;/weight&gt;


	&lt;/answer&gt;


	&lt;answer&gt;


		&lt;_text&gt; answer 3 text goes here&lt;/_text&gt;


		&lt;weight&gt;4&lt;/weight&gt;


	&lt;/answer&gt;


&lt;/Questions&gt;


&lt;Questions&gt;

</Patent_Guide>

I just cut and paste a portion of the xml file in there, dom’t be confused by the extra questions tag half way down, and apologies for the lack of indenting, that’s jus how it’s formatted on here.