Go Back To List
XML
Create an XML Sitemap or data feed with Classic ASP
Go Back To List
XML
Coding Article #: 31 - Published On: January 11, 2012 @ 13:21:09 PM - Last Updated on: July 13, 2012
This article has been Favorited 31 times
Join today, and add this to your favorites.
Coding Source - Share on MySpace Coding Source - Share With Facebook Coding Source - Share on Twitter Coding Source - Share on Reddit Coding Source - Share on Digg It Coding Source - Share on Stumble Upon It Coding Source - Share on Delicious
Share With Friends (Updated 6-8-2010)

Supported Files
Support Files! (Members Only)
Login (or) Register today!
Decompress with
Download winzip today!    (OR)    
Screenshot of Source Code
Coding Source - Create an XML Sitemap or data feed with Classic ASP
Using ASP Classic, we can create a Sitemap to be used with Google, Bing, and other search engines, as well as Data Feeds, to show live streaming content to your visitors.
Using this method, there are no limits to what you can accomplish, once you get started.

Example: View Live Example«

The database is structured as followed:


XMLID - AutoNumber (Primary Key)
XMLTitle - Short Text
XMLTime - Date/Time (Default value = Now() )




<%
' Using ACCESS Database
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("XML.mdb") & ";"
objConn.Open
' Below, we are going to set our XML Application, and write out our records.
%>
<% Response.ContentType="application/xml" %><?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><%Set getXML=CreateObject("ADODB.Command")
getXML.ActiveConnection=objConn
getXML.Prepared = true
getXML.commandtext = "SELECT XMLTime, XMLID, XMLTitle FROM ShowXML"
set rsXML = getXML.execute%><%
%><%while not rsXML.eof%>
<url>
  <loc><%=rsXML("XMLTitle")%></loc>
  <lastmod><%=rsXML("XMLTime")%></lastmod>
  <changefreq>always</changefreq>
</url><%rsXML.movenext
wend
'close and free our recordset and our database connection
rsXML.close
Set rsXML = nothing
objConn.close
Set objConn = nothing%></urlset>


You will notice in the code above, how we have the ending tags, nestled up against the closing of our ASP Tags.

Set objConn = nothing%></urlset>

The reasoning behind this. Is to make sure there are no spaces in the generated XML code.
If there are spaces, the page will render out an error.
Give it a test. Drop the </urlset> below, and you should get an error on the page when run.

Post to Facebook about: Create an XML Sitemap or data feed with Classic ASP