XML Question

I’m pretty much a “n00b” when it comes to XML and defining domian specific languages, but I have a problem and I think XML is the right solution. So, I’m writing up my question here on my blog so I can point to this post when I ask people for help. Here it goes …

I want to define a format for a text file that will allow me to quickly create a series of questions for a questionnaire. Once defined I intend to write a program (in Ruby) that will parse my text files and create questionnaires in HTML or PDF. At the most basic level, the text file might look like this:

Start Questionnaire
Q: Where were you born?
Select one
Outside Wisconsin
Q: Which device(s) do you own?
Select all that apply
Automobile, van, truck or motorcycle
Personal computer
Red plastic dinosaur
Q: When do you leave for work?
Enter time
End Questionnaire

A more XML-esque file might look more like this:

    <pre-question>Knowing where you were born is important when determining benefits.</>
    <question-text>Were you born in the United States?</>
    <answer type="radio" text="Select One">

Assume I need to create many dozens of these questionnaires on a regular basis.

My questions to the XML/DSL experts out there are:

  • How can I find out if someone has already created a schema for asking questions and providing answer options?
  • If I want to parse these text files into HTML forms using Ruby, is XML the way to go?
  • Is there a better way to do all of this?

Any answers or thoughts will be greatly appreciated! And, thanks in advance for your help.

1 thought on “XML Question”

Comments are closed.