如何用Asp动态生成xml文件
Function ReplaceChar ( FstrSource )
dim strRet
if IsNull(FstrSource) then
FstrSource = ""
end if
strRet = Replace ( FstrSource , "&" , "&" )
strRet = Replace ( strRet , "<" , "<" )
strRet = Replace ( strRet , ">" , ">" )
strRet = Replace ( strRet , """" , """ )
strRet = Replace ( strRet , "" , "'" )
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 & "&g
相关新闻>>
- 发表评论
-
- 最新评论 更多>>