Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

db to xml to asp?

Status
Not open for further replies.

guineamation

Programmer
Jan 29, 2002
58
IL
i found some information in the FAQ and on the net but couldn't get it to work.

How can i transform data from ACCESS DB to XML using ASP page and then read the XML from another ASP page?

example: i have in the DB a list of products and i want them in a SELECT LIST on an asp page.

thank you for your time! :)
 
what your referring to is xmlhttp

below is an example worked on a while back, you can view the source and the play with the javascript.

sample

the link below is the xml file(made from asp) using the letter "r" in ther querystring as an example.

xml file
 
One way to transform data from an access database into an XML file is to pull the data into an ADO recordset and then "persist" the recordset to disk. This will save the rows in the recordset as an XML file that can later be used to populate another ADO recordset from a file or for whatever other purpose you might have in mind.
 
below is how i populated the getproducts2.asp xml file

Code:
<%
Response.Expires =0
response.ContentType = "text/xml"

'Get the CategoryId selected from QueryString
mycategory = Request.QueryString("catid")

dim conn
dim rs
dim names

'conn is you connection string

set rs=conn.execute("select * from workers where firstName like '%" & mycategory & "%' or lastName like '%" & mycategory & "%'")

if rs.eof then
	Response.Write "<?xml version =""1.0"" encoding=""ISO-8859-1""?><Products><items><worker>None Found</worker></items></Products>"

else
myarray = rs.GetRows()

rs.close
set rs = nothing
conn.Close()
set conn = nothing
myrowcount = ubound(myarray,2)


if myrowcount > 0 then
	'Create XML ,One can use XMLDOM document to prepare XML or Stream object if ADO 2.7 or higher is used
	Response.Write "<?xml version =""1.0"" encoding=""ISO-8859-1""?><Products>"
	for jcount = 0 to myrowcount
	Response.Write "<items>"&vbcrlf
	Response.Write "<worker id =" & """" & myarray(0,jcount) & """" & ">" & myarray(1,jcount) &" " & myarray(2,jcount) &"</worker>"&vbcrlf
	Response.Write "<workerdesc>" & myarray(3,jcount) &"</workerdesc>"&vbcrlf
	Response.Write "</items>"&vbcrlf
	next 
	Response.Write "</Products>"
else
	'Create Error XML
	Response.Write "<?xml version =""1.0"" encoding=""ISO-8859-1""?><Products><items><worker>None Found</worker></items></Products>"
end if
end if
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top