Reputation: 237
I am trying to create a fairly simple editor with the purpose of having an easy way to create questionnaires which will then be sent to customers to fill them out and have em sent back to us. So the editor part is done with jquery, i just add the desired html elements (text/buttons) on button click. The visual part works. Now of course a created template should be savable and loadable via xml.
The saving to file part is what I have not yet figured out.
The way I was about to go was just taking the whole html document and parse it via php. But this seems to be a non-ideal solution.
The problem is that my experience is fairly limited and I just wanted to do this as a convenience/hobby project so I constantly feel like I am doing things the stupid way. So I am completely open to whichever way is best to accomplish this task.
So to give you an example i would have created:
<input type="checkbox" id="checkId1" /><label for="checkId1">Sample Answer</label>
<textarea type="text" name="questionText" id="questionText1" value="Sample Question Text"></textarea>
and want to convert this to an xml that looks sort of like
<Question>
<QuestionType>CheckboxQuestion</QuestionType>
<QuestionText>Sample Question Text</QuestionText>
</Question>
Which I am then going to convert back to html when parsed with jquery.
Upvotes: 0
Views: 139
Reputation: 56
I think this is what you mean!
1. you xml
<Question>
<QuestionType>CheckboxQuestion</QuestionType>
<QuestionText>Sample Question Text</QuestionText>
</Question>
2. Then parse xml using JS
$.ajax({
type:'GET',
url:'your xml file',
dataType:'xml',
success: function(data){
$(data).find("Question").each(function(){
$('div.caption').append("<input type='checkbox' id='checkId1'>"
+"<label for='checkId1'>"
+$(this).find('QuestionType').text()
+"</label>"
+"<textarea type='text' name='questionText' id='questionText1'" +"value='"$(this).find('QuestionText').text()"'>"
+"$(this).find('QuestionText').text()"
+"</textarea>");
});
}
});
3. HTML <div class='caption'></div>
Hope this will help! Tnx
Upvotes: 1