JSFiddle - React, Tailwind, and code Playground

by shaneblake

HTML

<div id="output"></div>

JavaScript

var xml = '<Salutation restricted="no" type="dropdownBox" tooltip="Select a title for the customer" required="yes" size="6"><value>Mr</value><value>Sir</value><value>Mrs</value><value>Miss</value><value>Lord</value></Salutation>';

    function dropdownBuilder(xml, element, id)
{
    // find node with specific name and get its children
    selection = $("<div>" + xml + "</div>").find(element).children();
    console.log(selection);
    // generate a select box
    var selectBox = "<select id=\"" + id + "\"> ";
selection.each(function(index) {
    var text = $(this).text();
    selectBox += "<option value=\"" + text + "\">" + text + "</option>";
});
    selectBox += "</select>";

    // return html
   $("#output").append(selectBox);

}


dropdownBuilder(xml, "Salutation", "Dropdown1");