<% 'Instancia o objeto XMLDOM. Set xmldoc = Server.CreateObject("MSXML2.DOMDocument.4.0") 'Nome e caminho completo de onde será salvo o arquivo nome = "e:\home\biano\web\democracias\rss\index.xml" 'O método createElement adiciona os elementos Set root = xmldoc.createElement("channel") xmldoc.appendChild (root) 'O método createProcessingInstruction possui 2 argumentos: o TARGET = "xml" e DATA = "version='1.0' encoding='ISO-8859-1'" Set inst = xmldoc.createProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'") xmldoc.insertBefore inst, root Set com = xmldoc.createComment("Gerado pelo sistema Bloguim BETA") xmldoc.insertBefore com, root Set titulo = xmldoc.createElement("title") titulo.Text = "Democracias - Blog Crítico" root.appendChild (titulo) Set link = xmldoc.createElement("link") link.Text = "http://biano.com.br/democracias" root.appendChild (link) Set descricao = xmldoc.createElement("description") descricao.Text = "Blog crítico ... por Bruno Muller, Fabiano Carnevale e Fabricio Pereira" root.appendChild (descricao) Set linguagem = xmldoc.createElement("language") linguagem.Text = "pt-br" root.appendChild (linguagem) Set imagem = xmldoc.createElement("image") 'O método appendChild adiciona um elemento filho ao elemento atual xmldoc.documentElement.appendChild (imagem) Set imgUrl = xmldoc.createElement("url") imgUrl.Text = "http://biano.com.br/democracias/dblog.jpg" imagem.appendChild (imgUrl) xmldoc.documentElement.appendChild (imagem) Set imgTitle = xmldoc.createElement("title") imgTitle.Text = "Democracias Blog" imagem.appendChild (imgTitle) xmldoc.documentElement.appendChild (imagem) Set imgLink = xmldoc.createElement("link") imgLink.Text = "http://biano.com.br/democracias" imagem.appendChild (imgLink) Set linguagem = xmldoc.createElement("language") linguagem.Text = "pt-br" root.appendChild (linguagem) sql = "SELECT * FROM notas ORDER by id DESC" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, MeuDB, 3, 3 Conta = 0 Do While not rs.eof AND Conta < 10 sqlAutor = "SELECT * FROM autores WHERE id = " & rs("idAutor") Set rsAutor = Server.CreateObject("ADODB.Recordset") rsAutor.Open sqlAutor, MeuDB, 3, 3 Set notas = xmldoc.createElement("item") root.appendChild (notas) Set nottitle = xmldoc.createElement("title") nottitle.Text = rs("titulo") notas.appendChild (nottitle) Set notlink = xmldoc.createElement("link") notlink.Text = "http://biano.com.br/democracias/notas.asp?id=" & rs("id") notas.appendChild (notlink) Set notpubdate = xmldoc.createElement("pubDate") notpubdate.Text = FormatDateTime(rs("dt"),1) notas.appendChild (notpubdate) Set notcreator = xmldoc.createElement("dc:creator") notcreator.Text = rsAutor("nome") notas.appendChild (notcreator) Set notdescricao = xmldoc.createElement("description") notdescricao.Text = left(rs("texto"), 250) notas.appendChild (notdescricao) Set notguid = xmldoc.createElement("guid") notguid.Text = "http://biano.com.br/democracias/notas.asp?id=" & rs("id") notas.appendChild (notguid) mtzCat = SPLIT(rs("idCategorias"), ",") MaxConta = Ubound(mtzCat) For i=0 to MaxConta sql = "SELECT * FROM categorias WHERE id = " & mtzCat(i) Set rsCat = Server.CreateObject("ADODB.Recordset") rsCat.Open sql, MeuDB, 3, 3 Set notcategorias = xmldoc.createElement("category") notcategorias.Text = lcase(rsCat("nome")) notas.appendChild (notcategorias) Next Conta = Conta + 1 rs.movenext Loop 'Salva o arquivo no caminho especificado xmldoc.save (nome) Response.write "Arquivo salvo !" 'Destruíndo os objetos Set xmldoc = Nothing Set root = Nothing Set inst = Nothing Set com = Nothing Set imagem = Nothing Set imgUrl = Nothing Set imgTitle = Nothing Set imgLink = Nothing Set descricao = Nothing Set linguagem = Nothing Set notas = Nothing Set nottitle = Nothing Set notlink = Nothing Set notpubdate = Nothing Set notcreator = Nothing Set notdescricao = Nothing Set notguid = Nothing Set notcategorias = Nothing %>