lines to xml

Just a little tool I needed.

by mich

HTML

<textarea id="thearea"></textarea><br /><button onclick="xmlify()">XML</button>

CSS

textarea {
    width: 100%;
    height: 300px;
}

JavaScript

function xmlify( ) {
        var thearea = document.getElementById('thearea');
    var textArray = thearea.value.split("\n");
    var newText = '';
    for(a=0;a<textArray.length; a+=3) {
       newText = newText  + "\t\t\t\t<mod_artist>\n";
        newText = newText + "\t\t\t\t\t<username>" + textArray[a] + "</username>\n";
        newText = newText + "\t\t\t\t\t<status>" + textArray[a+1] + "</status>\n";
        newText = newText + "\t\t\t\t\t<comment>" + textArray[a+2] + "</comment>\n";
        newText = newText + "\t\t\t\t</mod_artist>\n";
    }
    thearea.value = newText;
}