--[[ Copyright (c) 2013 Remko Tronçon Licensed under the GNU General Public License v3. See Documentation/Licenses/GPLv3.txt for more information. --]] example_form = [[ Bot Configuration Fill out this form to configure your new bot! jabber:bot Section 1: Bot Info Section 2: Features news search Section 3: Subscriber List 20 Section 4: Invitations Tell all your friends about your new bot! ]] form = sluift.from_xml(example_form)['data'] print(form) -- Test form properties assert(form['title'] == 'Bot Configuration') -- Test boolean field public_field = form['fields'][5] assert(public_field['name'] == 'public') assert(type(public_field['value']) == 'boolean') assert(public_field['required'] == true) -- Test multi field features_field = form['fields'][8] assert(features_field['name'] == 'features') assert(type(features_field['values']) == 'table') assert(#features_field['values'] == 2) assert(features_field['values'][1] == 'news') assert(features_field['values'][2] == 'search') -- Test shortcut index assert(form['features']['name'] == 'features') assert(form['FORM_TYPE']['value'] == 'jabber:bot') -- Test response form print(form:create_submission()) --print(sluift.to_xml({type = 'form', data = form}))