I am working on a project where I am saving my data in xml format.I am unable to save double quotes in my data.I have tried replacing double quotes with " but it didn't worked.Please suggest how to achieve this.
Following is the xml data which I am passing
<question HasOptions="0" answer=""I think ki I am vulnerable"...text check // "i am afraid"" QuestionId="2042" OptionId="1260" ></question>
My javascript code for xml creation
function GetXMLForPosting() {
// here is the XML for posting
var xmlqQuestionResponse = '<question HasOptions="{{hasOptions}}" answer="{{score}}" QuestionId="{{questionID}}" OptionId="{{optionID}}" />';
var answers = '';
//lopping through questions
$('.little_text').each(function () {
// question data
hasOptions = $(this).attr('hasoptions');
questionID = $(this).attr('questionid');
// option data
selectedOption = $(this).find('input[name=radio_' + questionID + ']:checked');
score = $(selectedOption).attr('value');
optionID = $(selectedOption).attr('id');
// end
if (questionID > 0) {
if (hasOptions == 0) {
// case of textarea
// overiding default values
selectedOption = $(this).find('textarea[name=radio_' + questionID + ']');
score = $(selectedOption).val();
optionID = '1260';
answers = answers + xmlqQuestionResponse
.replace('{{hasOptions}}', hasOptions)
.replace('{{score}}', score.replace(/\'/g, "\'"))
.replace('{{questionID}}', questionID)
.replace('{{optionID}}', optionID);
}
else {
// normal radio button
answers = answers + xmlqQuestionResponse
.replace('{{hasOptions}}', hasOptions)
.replace('{{score}}', score)
.replace('{{questionID}}', questionID)
.replace('{{optionID}}', optionID);
}
}
});
//console.log('<questions>' + answers + '</questions>');
return '<questions>' + answers + '</questions>';
}
here my answer is coming in score option
My cs code
[HttpPost]
public ActionResult Postback(FormCollection formCollection)
{
// Process the take questionnaire
var model = (WorkflowMessage)Session[Enumerations.SessionItems.ViewModel];
// Check the page guid redirect accoringly
if (!GuidValid())
return ReshowPage();
var rawData = formCollection[Enumerations.FlashVariableFormPostKey.OutputData];
var enc = Encoding.GetEncoding("ISO-8859-1");
var responseXml = HttpUtility.UrlDecode(rawData, enc);
// redundant variable left so that at debug time the result can be inspected.
var result = new QuestionnaireService().SaveTakenQuestionnaire(PatientSessionDataObject.TreatmentId, model.PatientId, PatientSessionDataObject.CustomerId, model.AssetData, rawData);
return RedirectToAction("Next", "Treatment", new { navigationChosen = "Next", area = string.Empty, model.PageCheckGuid });
}
Please suggest how I can save text-"I think ki I am vulnerable"...text check // "i am afraid" in my answer field.Thanks