uml – xtUML: Next question depending on multiple previous answers

I want to write an application where the user has to answer several questions. The difficulty is that the third question might depend on the answers of question 1 and 2. For example:

  1. question A: possible answers A1 / A2 / A3
  2. question B: possible answers B1 / B2 / B3
  3. a. question C only if the previous answers where (A1 or A2) and B1
  4. b. question D for all other cases (if A3 or B2 or B3)

The questions and the possible answers should be written in some file, so they could be exchanged easily. And we need some code that always knows which question to ask next. I was thinking of xtUML but couldnā€˜t find anything that suits our needs.

Our code is going to be written in Perl. But anything (also in other programming languages) is welcome. Maybe someone thought this through and we can transform his ideas.

Do you have any idea what could help me here?