<% Sub zFile_XML(SaveXmlTo,ByVal IncludeComments) 'includecomments is a number If SaveXmlTo = "" Then 'no filename given to save to / no stream requested Exit Sub End If If IncludeComments = 0 Then IncludeComments = 1000 End If Dim zobjXML Set zobjXML = Server.CreateObject("Microsoft.XMLDOM") zobjXML.preserveWhitespace = True 'Set zobjXML = Server.CreateObject("Msxml2.XMLDocument") 'msxml v3 zobjXML.appendChild(zobjXML.createProcessingInstruction("xml","version=""1.0""")) 'xml declaration zobjXML.appendChild(zobjXML.createElement("news_page")) 'root Dim zobjXML1 '-- create the news_post node -- Set zobjXML1 = zobjXML.createElement("news_post") 'create new node zobjXML1.appendChild(zobjXML.createElement("posted_by")) 'add children zobjXML1.appendChild(zobjXML.createElement("posted_date")) zobjXML1.appendChild(zobjXML.createElement("category")) zobjXML1.appendChild(zobjXML.createElement("title")) zobjXML1.appendChild(zobjXML.createElement("content")) zobjXML1.appendChild(zobjXML.createElement("comments")) Dim zobjXML2 Set zobjXML2 = zobjXML1.cloneNode(True) 'save this node, without values Dim i,zLimit zLimit = UBound(zobjRS,2) For i = 0 to zLimit zobjXML1.setAttribute "postid",zobjRS(0,i) 'postid zobjXML1.setAttribute "userid",zobjRS(8,i) 'userid zobjXML1.childNodes(0).setAttribute "email",zobjRS(7,i) 'email of user zobjXML1.childNodes(0).text = zobjRS(6,i) 'username zobjXML1.childNodes(1).text = zobjRS(2,i) 'date posted zobjXML1.childNodes(2).setAttribute "catid",zobjRS(9,i) 'category id zobjXML1.childNodes(2).text = zobjRS(5,i) 'category name zobjXML1.childNodes(3).text = zobjRS(1,i) 'title zobjXML1.childNodes(4).text = zFilter_Reverse(zobjRS(3,i)) 'content - the filter returns it to HTMLEncoded zobjXML1.childNodes(5).setAttribute "amount",zobjRS(4,i) 'no of comments attribute of comments '-- now comments -- If IncludeComments <> -1 And CInt(zobjRS(4,i)) > 0 Then zobjRS1.Filter = "PostID LIKE " & zobjRS(0,i) 'get comments collection Dim ii ii = 1 If Not zobjRS1.EOF Then Do While Not zobjRS1.EOF And ii <= IncludeComments zobjXML1.childNodes(5).appendChild(zobjXML.createElement("comment")) 'adds a child to the comments node zobjXML1.childNodes(5).childNodes(ii-1).setAttribute "commentid",zobjRS1("CommentID") 'comment id zobjXML1.childNodes(5).childNodes(ii-1).setAttribute "by",zobjRS1("PostedBy") 'name of commenter zobjXML1.childNodes(5).childNodes(ii-1).setAttribute "date",zobjRS1("PostedDate") 'date it was commented zobjXML1.childNodes(5).childNodes(ii-1).text = zFilter_Reverse(zobjRS1("Comment")) 'the filter returns it to HTMLEncoded zobjRS1.MoveNext ii = ii + 1 Loop End If End If 'end comments zobjXML.documentElement.appendChild(zobjXML1.cloneNode(True)) 'save this new node to xml Set zobjXML1 = zobjXML2 'reset the node that gets written to Next zobjXML.Save(Server.MapPath("/kaos/generated/" & SaveXmlTo & ".xml")) 'zobjXML.Save(Server.MapPath(SaveXmlTo & ".xml")) '-- close down -- Set zobjXML = Nothing Set zobjXML1 = Nothing Set zobjXML2 = Nothing End Sub %>