response.write RecordsetToXML (rs, "table",pageno,21)
Response.ContentType="text/xml"
sub.asp
Function RecordsetToXML (oRec, sName,Pageno,pagesize)
Dim oFld
Dim sXML
Dim sSpaces
Dim sNames
Dim RecNo
dim sConvert
sSpaces = Space (iLevel * 2)
If Right(sName, 1) = "S" then
sNames = sName
sName = Left (sName, Len(sName) - 1)
else
sNames = sName &
"S"
End If
sXML = sSpaces &
"<" &
sNames &
">" &
vbCR
iLevel = iLevel + 1
sSpaces = Space (iLevel * 2)
oRec.MoveFirst
RecNo=(Pageno-1)*Pagesize
oRec.move(RecNo)
For intRecord = 1 To PageSize
RecNo=RecNo+1
sXML = sXML &
sSpaces &
"<" &
sName &
">" &
vbCR
sXML = sXML &
sSpaces &
" <idno>" &left("........",len(pageno*pagesize)-len(RecNo))&RecNo &
"</idno>" &
vbCR
For Each oFld In oRec.Fields
If oFld.Type = adChapter then
Set oChapter = oFld.Value
If Not oChapter.EOF then
iLevel = iLevel + 1
sXML = sXML &
RecordsetToXML (oChapter, oFld.Name)
iLevel = ilevel - 1
End If
else
sXML = sXML &
sSpaces &
" " &
"<" &
oFld.Name &
">" &
oFld.Value &
"</" &
oFld.Name &
">" &
vbCR
End If
Next
sXML = sXML &
sSpaces &
"</" &
sName &
">" &
vbCR
oRec.MoveNext
If oRec.EOF then
Exit For
Next
iLevel = iLevel - 1
sSpaces = Space (iLevel * 2)
sXML = sXML &
sSpaces &
"</" &
sNames &
">" &
vbCR
RecordsetToXML = sXML
End Function