xml(row_name,rows_name)

This commit is contained in:
mdipierro
2012-08-26 00:00:15 -05:00
parent 6577c656be
commit 4e719c5858
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-08-25 23:54:19) dev
Version 2.00.0 (2012-08-26 00:00:11) dev
+6 -3
View File
@@ -8886,13 +8886,13 @@ class Rows(object):
row.append(none_exception(value))
writer.writerow(row)
def xml(self,strict=False):
def xml(self,strict=False,row_name='row',rows_name='rows'):
"""
serializes the table using sqlhtml.SQLTABLE (if present)
"""
if strict:
ncols = len(self.colnames)
def f(row,field='row',indent=' '):
def f(row,field,indent=' '):
if isinstance(row,dict):
spc = indent+' \n'
items = [f(row[x],x,indent+' ') for x in row]
@@ -8906,7 +8906,10 @@ class Rows(object):
return '%s<%s>%s</%s>' % (indent,field,row,field)
else:
return None
return '<rows>\n%s\n</rows>' % '\n'.join(f(row) for row in self)
return '<%s>\n%s\n</%s>' % (
rows_name,
'\n'.join(f(row,row_name) for row in self),
rows_name)
import sqlhtml
return sqlhtml.SQLTABLE(self).xml()