Now that it is needed since web2py exports already in CSV but you can do define
def export_xml(rows):
idx=range(len(rows.colnames))
colnames=[item.replace('.','_') for item in rows.colnames]
records=[]
for row in rows.response: records.append(TAG['record'](*[TAG[colnames[i]](row[i]) for i in idx]))
return str(TAG['records'](*records))
Now if you have a model like
db=SQLDB('sqlite://test.db')
db.define_table('mytable',SQLField('myfield'))
for i in range(100): db.mytable.insert(myfield=i)
you can get your data in XML by doing
print export_xml(db().select(db.mytable.ALL))
Notice that
TAG.name('a','b',c='d')
and
TAG['name']('a','b',c='d')
both generate the following XML
<name c="d">ab</name>
where 'a' and 'b' and 'd' are escaped as appropriate. Using TAG you can can generate any HTML/XML tag you need and is not already provided in the API. TAGs can be nested and are serialized with str()