SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I get XML dynamically from a database?

    I am trying to get my data dynamically from sql server and put it into xml format for a new page i am working on. I am trying to work on some dhtml menus (like the MS TOC) and they have an example where the data is posted in an xml file. I want to grab the data from my db and get it in that same format.

    Heres my query:

    Code:
     <select name="ssmenuWOMEN4" onChange="changeWOMEN4()" size="1" style=font-family:Arial;font-size:10px>
      <option selected value="none">--Women's Dresses--</option>
    
    <%MSQL= "SELECT DISTINCT store_dept.dept_name, store_dept.dept_id, store_dept.parent_id 
    FROM store_product 
    INNER JOIN (store_dept INNER JOIN store_dept_prod ON store_dept.dept_id = store_dept_prod.dept_id) 
    ON store_product.sku = store_dept_prod.sku 
    WHERE (((store_dept.parent_id)=208))"
    
    set pulldown = server.CreateObject("adodb.recordset")
         pulldown.Open msql,Application("NotMyConnectionString"),adOpenStatic
    
    do while not pulldown.EOF 
      tmpname = pulldown(0).value
    %>
    
    <option value="dept.asp?dept_id=<%=pulldown(1)& mscssid%>"><%=tmpname%></option>
    
    <% pulldown.MoveNext 
          loop
          pulldown.Close 
    %>
    </select>
    Here is the xml format from MS:

    Code:
    <TOPICLIST TYPE ="Womens Clothing">
    <TOPICS TYPE="Dresses">
    	<TOPIC><SIZE>Size 8</SIZE><URL>dept.asp?dept_id=2081</URL></TOPIC>
    	<TOPIC><SIZE>Size 9</SIZE><URL>dept.asp?dept_id=2082</URL></TOPIC>
    	<TOPIC><SIZE>Size 10</SIZE><URL>dept.asp?dept_id=2083</URL></TOPIC>
    </TOPICS>
    </TOPICLIST>
    Thanks in advance!

  2. #2
    Xbox why have you forsaken me? moospot's Avatar
    Join Date
    Feb 2001
    Location
    Clearwater, FL
    Posts
    3,615
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I got it now..found it at www.w3schools.com

    Code:
    <%
    Response.ContentType = "text/xml"
    
    MSQL= "SELECT DISTINCT store_dept.dept_name, store_dept.dept_id, store_dept.parent_id 
    FROM store_product 
    INNER JOIN (store_dept INNER JOIN store_dept_prod ON store_dept.dept_id = store_dept_prod.dept_id) 
    ON store_product.sku = store_dept_prod.sku WHERE (((store_dept.parent_id)=208))"
    
    set rs = server.CreateObject("adodb.recordset")
    rs.Open msql,Application("store_ConnectionString"),adOpenStatic
    
    rs.MoveFirst()
    response.write("<?xml version='1.0' ?>")
    response.write("<womens dresses>")
    while (not rs.EOF)
    response.write("<dresses>")
    response.write("<size>" & rs("dept_name") & "</size>")
    response.write("<url>dept.asp?dept_id=" & rs("dept_id") & "</url>")
    response.write("</dresses>")
    rs.MoveNext()
    wend
    rs.close()
    
    response.write("</womens dresses>")
    %>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •