what is CDATA?

what is CDATA?

על ידי jeff ciaccio בתאריך
מספר תגובות: 5

I am trying to create an Excel file that will generate the proper XML code. I am using Excel 2000, and it does not seem to like the macros that others have created in 2003 and beyond.


I am getting the following error: Parsing questions from import file.

Error importing question Invalid xml file - string expected (use CDATA?)


Here is my xml:


<?xml version="1.0" encoding="UTF-8"?>

<quiz>

<question type='shortanswer'> <name><text>KBr</name></text> <questiontext format 'html'><text>If potassium and bromine combine to form an ionic compound, what is the result of that reaction? To enter a subscript, use sub.<br>For example Li<sub>2</sub>O is entered Lisub2O</text></questiontext> <generalfeedback>Be sure to look up the value of each of the ion's charge and criss-cross if they do not add to zero.</generalfeedback> <defaultgrade>1</defaultgrade> <penalty>0.1</penalty> <hidden>0 </hidden> <shuffleanswers>0</shuffleanswers> <usecase>1</usecase> <answer fraction="100>" <text>KBr</text> <feedback><text>Correct, it is KBr!</text></feedback></answer> </question>

</quiz>

Any suggestions?

ממוצע דרוגים: -
בתגובה ל: jeff ciaccio

Re: what is CDATA?

על ידי Itamar Tzadok בתאריך
There is a quote problem in

<answer fraction="100>"

In the Excel you may need to escape apostrophes

each of the ion\'s charge and

Here is an example of how CDATA may look like:

="<question type='multichoice'><name><text><![CDATA["&L25&"]]></text></name><questiontext format='html'><text><![CDATA["&M25&"]]></text></questiontext><penalty>0</penalty><hidden>0</hidden><shuffleanswers>1</shuffleanswers><single>true</single>"

Hope this helps. חיוך
בתגובה ל: jeff ciaccio

Re: what is CDATA?

על ידי Matt Bury בתאריך
תמונה של Plugin developers
Hi Itamar,

To answer your question, CDATA is an XML tag that allows you to include special characters that would otherwise get parsed by any XML reading software. Special characters are things like =,",\,{}, etc.

For example, the following tag in an XML file would play havoc with an XML parser if it weren't in a CDATA tag:

this="that" myemail@mailbox.com {a:100 b:200 c:300 d:400} \'escape\' \n etc.

I hope this answers your question.

All the best,

Matt
בתגובה ל: Matt Bury

Re: what is CDATA?

על ידי jeff ciaccio בתאריך
Thanks guys! I thought I had changed all of my double quotes to single, but I guess this slipped past me.
בתגובה ל: jeff ciaccio

Re: what is CDATA?

על ידי Kristin Dougherty בתאריך

I know this message is a little late but I came across this website that is very helpful for when you are using apostrophe's and quotes, etc.

http://www.tedmontgomery.com/tutorial/htmlchrc.html

The problem I have now is I can't get Moodle to bulk upload questions that I want to be bold.. i have tried the following codes and get the same error as you had...

<b>  </b>

<strong>    </strong>

<span style="font-weight: bold;">      </span>

בתגובה ל: jeff ciaccio

Re: what is CDATA?

על ידי Howard Miller בתאריך
תמונה של Core developers תמונה של Documentation writers תמונה של Particularly helpful Moodlers תמונה של Peer reviewers תמונה של Plugin developers
This answer is even later, but just for the record some of the answers have missed the point.

You can't have HTML buried inside the XML. It will break the XML and that's why the OP is getting the error. The point is that if you want to include arbitrary HTML between the 'text' tags then you need to include it in a CDATA section. CDATA escapes all that is within it, forcing it to be interpreted as simple text not XML markup.

See http://en.wikipedia.org/wiki/CDATA

See Moodle_XML_format for an example.