<% Sub make_sql() zstrSQL = "SELECT news.PostID, news.Title, news.PostedDate, news.Category, news.DateStamp, userInfo.UserID, userInfo.UserName FROM news INNER JOIN userInfo ON news.PostedBy LIKE userInfo.UserID WHERE " If HeadlineDays > 0 Then Dim zTmpDate1 zTmpDate1 = DateAdd("d",(HeadlineDays * -1),Now) 'gets date from [zstrDaysBack] days ago zTmpDate1 = Year(zTmpDate1) & Right("0"&Month(zTmpDate1),2) & Right("0"&Day(zTmpDate1),2) 'converts it to yyyymmdd zstrSQL = zstrSQL & "news.DateStamp >= " & zTmpDate1 & " AND " End If If InStr(HeadlineCategory,",") <> 0 Then 'multiple categories zstrSQL = zstrSQL & "news.Category IN (" & HeadlineCategory & ") " Else 'single zstrSQL = zstrSQL & "news.Category LIKE " & HeadlineCategory & " " End If zstrSQL = zstrSQL & "ORDER BY news.PostID DESC" End Sub Sub closedown_rs() zobjRS1.Close zobjConn.Close Set zobjRS1 = Nothing Set zobjConn = Nothing End Sub Sub write_xml() '-- XML -- Dim zobjXML Set zobjXML = Server.CreateObject("Microsoft.XMLDOM") zobjXML.appendChild(zobjXML.createProcessingInstruction("xml","version=""1.0""")) 'xml declaration zobjXML.appendChild(zobjXML.createElement("headlines")) 'document root '-- set the target url for the links -- zobjXML.documentElement.appendChild(zobjXML.createElement("target_url")) zobjXML.documentElement.childNodes(0).text = HeadlineURL Dim zobjXML1,zobjXML2 '-- create the headline node -- Set zobjXML1 = zobjXML.createElement("headline") 'create zobjXML1.appendChild(zobjXML.createElement("title")) 'add children zobjXML1.appendChild(zobjXML.createElement("posted_date")) zobjXML1.appendChild(zobjXML.createElement("posted_by")) Set zobjXML2 = zobjXML1.cloneNode(True) 'save this empty node setup in memory '-- insert values into node -- Dim i,zLimit zLimit = UBound(zobjRS,2) For i = 0 to zLimit '# zobjXML1 is always a new, clean node. thanks to saving the node earlier, and resetting at the end of the loop zobjXML1.setAttribute "postid",zobjRS(0,i) 'postid zobjXML1.setAttribute "category",zobjRS(3,i) 'category zobjXML1.childNodes(0).text = zobjRS(1,i) 'title zobjXML1.childNodes(1).text = zobjRS(2,i) 'posted date zobjXML1.childNodes(1).setAttribute "stamp",zobjRS(4,i) 'date stamp zobjXML1.childNodes(2).setAttribute "userid",zobjRS(5,i) 'user id zobjXML1.childNodes(2).text = zobjRS(6,i) 'name zobjXML.documentElement.appendChild(zobjXML1.cloneNode(True)) 'add this node to the xml document Set zobjXML1 = zobjXML2 'set zobjXML1 to the clean node saved earlier Next zobjXML.Save(Server.MapPath("/kaos/generated/headlines.xml")) 'save the now fully written xml to a file on the server 'zobjXML.Save(Server.MapPath("headlines.xml")) '-- close down -- Set zobjXML = Nothing Set zobjXML1 = Nothing Set zobjXML2 = Nothing End Sub '-- gubbins -- Dim zobjRS,zobjRS1,zstrSQL Call make_sql() Set zobjRS1 = Server.CreateObject("ADODB.Recordset") zobjRS1.CursorLocation = 3 zobjRS1.Open zstrSQL, zobjConn, adOpenForwardOnly, adLockReadOnly, adCmdText If Not zobjRS1.EOF Then If zobjRS1.RecordCount > HeadlinePosts Then zobjRS = zobjRS1.GetRows(HeadlinePosts) 'number of news posts to include in file Else zobjRS = zobjRS1.GetRows() End If Call closedown_rs() Call write_xml() Else Call closedown_rs() End If %>