欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何用Asp动态生成xml文件

程序员文章站 2022-06-04 11:54:12
function replacechar ( fstrsource )  dim strret  if isnull(fstrsource) then  &n...

function replacechar ( fstrsource )
  dim strret
  if isnull(fstrsource) then
    fstrsource = ""
  end if
  strret = replace ( fstrsource , "&" , "&" )
  strret = replace ( strret , "<" , "&lt;" )
  strret = replace ( strret , ">" , "&gt;" )
  strret = replace ( strret , """" , "&quot;" )
  strret = replace ( strret , "" , "&apos;" )
  replacechar = strret
end function
function rsttoxml(标准化越来越近了) (frstrst, fstrrstname)
    dim strspace  space string behand of element
    dim intlevel  level of the element
    dim strxml(标准化越来越近了)    the return string(xml(标准化越来越近了) string)
    dim intrstfield
    dim strshortdate
   
    document level
    intlevel = 0
    strspace = space (intlevel * 2)
    if len(fstrrstname)>0 then
    strxml(标准化越来越近了)=strspace & "<" & fstrrstname & ">" & vbcr
    intlevel = intlevel + 1
    strspace = space(intlevel*2)
  end if
  if frstrst.eof then
    strxml(标准化越来越近了) = strxml(标准化越来越近了)&strspace & "<record"
    for ncount=0 to frstrst.fields.count-1
      strxml(标准化越来越近了) = strxml(标准化越来越近了) & space(1)&frstrst.fields(ncount).name&"="
    next
    strxml(标准化越来越近了) = strxml(标准化越来越近了) & "/>" &vbcr
    if len(fstrrstname)>0 then
    strxml(标准化越来越近了)=strxml(标准化越来越近了)&strspace & "</" & fstrrstname & ">" & vbcr
    end if
    rsttoxml(标准化越来越近了)=strxml(标准化越来越近了)
    exit function
  end if

  now move in one level
  intlevel = intlevel + 1
  strspace = space (intlevel * 2)
 
  loop through the records
  dim strtemp
  frstrst.movefirst
  do while not frstrst.eof
    strtemp = ""
      loop through the fields
      strxml(标准化越来越近了) = strxml(标准化越来越近了) & strspace & "<record"
      for each objfield in frstrst.fields
      set objfield = frstrst.fields(intrstfield)
          strtemp = strtemp & space (1) & objfield.name & "="
             strtemp = strtemp & """" & replacechar(objfield.value)  & """"
      end if
      next
      strxml(标准化越来越近了) = strxml(标准化越来越近了) & "<record "&strtemp& "/>" & vbcr
      frstrst.movenext
  loop
 
  intlevel=intlevel-1
  strspace=space(intlevel * 2)

  if len(fstrrstname)>0 then
    strxml(标准化越来越近了) = strxml(标准化越来越近了) & strspace & "</" & fstrrstname & ">" & vbcr
  end if

  rsttoxml(标准化越来越近了) = strxml(标准化越来越近了)