'How can I automate adding values in a cell from Excel into an xml code?
I have [data][1] in a table on an excel spreadsheet. I want to be able to automatically add the data at specific locations inside my code. The output format is .xml.
How can I do this in a way that lets me automatically generate an .xml file with the required code?
I am creating questions for a question bank with question tags. The system I am uploading to requires questions to be uploaded through the .xml format. Below is an example of the code required to import a new question. How can I create an automated function that transposes the values from the excel spreadsheet into the code and (if possible) saves the code as an .xml file ready for upload? Ideally I'd like one file to encompass all the questions in a single spreadsheet (<200 questions).
The variables are identified by two asterisks (*) on either side throughout the code.
-<quiz>
<!-- question: 0 -->
-<question type="category">
-<category>
<text>$course$/top/Default for CT</text>
</category>
-<info format="moodle_auto_format">
<text>The default category for questions shared in context 'CT'.</text>
</info>
<idnumber/>
</question>
<!-- question: **1732** -->
-<question type="multichoice">
-<name>
<text>**B1L3V115R1**</text>
</name>
-<questiontext format="html">
-<text>
-<![CDATA[<p><span style="font-size: 14px;">**One hundred _____ makes up one dollar.**</span></p><p><br></p>]]>
</text>
</questiontext>
-<generalfeedback format="html">
<text/>
</generalfeedback>
<defaultgrade>1.0000000</defaultgrade>
<penalty>0.0000000</penalty>
<hidden>0</hidden>
<idnumber/>
<single>true</single>
<shuffleanswers>true</shuffleanswers>
<answernumbering>abc</answernumbering>
<showstandardinstruction>0</showstandardinstruction>
-<correctfeedback format="html">
<text>Your answer is correct.</text>
</correctfeedback>
-<partiallycorrectfeedback format="html">
<text>Your answer is partially correct.</text>
</partiallycorrectfeedback>
-<incorrectfeedback format="html">
<text>Your answer is incorrect.</text>
</incorrectfeedback>
<shownumcorrect/>
-<answer format="html" fraction="**100**">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">cents</p>]]>
</text>
-<feedback format="html">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**سنت**</p>]]>
</text>
</feedback>
</answer>
-<answer format="html" fraction="**0**">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**nickels**</p>]]>
</text>
-<feedback format="html">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**سنت**</p>]]>
</text>
</feedback>
</answer>
-<answer format="html" fraction="**0**">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**percent**</p>]]>
</text>
-<feedback format="html">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**سنت**</p>]]>
</text>
</feedback>
</answer>
-<answer format="html" fraction="**0**">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**dime**</p>]]>
</text>
-<feedback format="html">
-<text>
-<![CDATA[<p dir="ltr" style="text-align: left;">**سنت**</p>]]>
</text>
</feedback>
</answer>
-<tags>
-<tag>
<text>**noun**</text>
</tag>
-<tag>
<text>**B1L3V115R1**</text>
</tag>
-<tag>
<text>**V**</text>
</tag>
-<tag>
<text>**Cent**</text>
</tag>
-<tag>
<text>**V115**</text>
</tag>
-<tag>
<text>**B1L3**</text>
</tag>
-<tag>
<text>**American Money**</text>
</tag>
+<tag>
-<tag>
<text>**V115R1**</text>
</tag>
</tags>
</question>
</quiz>```
[1]: https://i.stack.imgur.com/BWSB9.png
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
