How to generate dynamic XML from aspx page

G

Guest

Dear Friends,
I was using the below code in ASP to dynamically generate XML from a SQL Query
Does anyone knows how can I migrate this code to VB and ASPX?

Regards
Robson Machado

Response.ContentType = "text/xml"
Response.Write "<?xml version='1.0' ?>"
dim RS, CN
set CN = server.CreateObject("adodb.connection")
set RS = server.CreateObject("adodb.recordset")
CN.ConnectionString = strConnect
CN.Open
RS.Open SQLStmt,cn
Response.Write "<ROOT>"
Response.Write RS2XML(RS,"RESULT")
Response.Write "</ROOT>"
CN.close
set rs = nothing
set cn = nothing
function RS2XML(rs, ChildNode)
dim Field
if rs is nothing then exit function
ChildNode = ucase(ChildNode)
if rs.eof then
RS2XML = ""
exit function
end if
do until rs.eof
if ChildNode <> "" then RS2XML = RS2XML & "<" & ChildNode & ">"
for each field in rs.fields
RS2XML = RS2XML & " <" & ucase(field.name) & ">" &
server.HTMLEncode(NotNull(field.value)) & "</" & ucase(field.name) & ">"

next
if ChildNode <> "" then RS2XML = RS2XML & "</" & ChildNode & ">"
rs.movenext
loop
end function
Function NotNull(vOrig)
If(IsNull(vOrig)) then
NotNull = ""
else
NotNull = vOrig
end if
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top