Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

asp.net

[Resolvido] Gerando XML com ASP

Recommended Posts

'ARQUIVO DE CONEXÃO COM O BANCO

<!--#include file="reret.asp"-->

 

'DECLARAÇÃO DAS VARIÁVEIS

Dim arquivoxml, servidores, busca_servidores, total_emprestimo, total_prestacao, total_contratos

 

'CRIAÇÃO DA INSTANCIA DO OBJETO MSXML

Set arquivoxml = Server.CreateObject("MSXML2.DOMDocument.3.0")

 

'DETERMINANDO O CABECALHO DO ARQUIVO

set cabecalho=arquivoxml.createprocessinginstruction("xml","version='1.0'")

arquivoxml.insertbefore cabecalho,raiz

'CRIAÇÃO DO ARQUIVO

Set servidores = arquivoxml.CreateElement("servidores")

Set dateAttr = arquivoxml.CreateAttribute("data")

'ATRIBUINDO A DATA PARA A CRIACAO DO ARQUIVO

servidores.attributes.SetNamedItem(dateAttr)

 

' PASSO O ARQUIVO CRIADO PARA O OBJETO XML

Set arquivoxml.documentElement = servidores

 

'BUSCA SQL NO BANCO

busca_servidores = "Select * from governo where digitacao=true"

reret.Open busca_servidores

 

'VARRENDO O BANCO E PASSANDO OS VALORES PARA OS OBJETO DO ARQUIVO XML

while not reret.eof

 

total_contratos = total_contratos+1

total_emprestimo = total_emprestimo + Reret("emprestimo")

total_prestacao = total_prestacao + reret("valor_prestacao")

 

'CRIAÇÃO DO NO INFORMACOESSERVIDORES

Set informacoesservidor = arquivoxml.CreateElement("informacoesservidor")

 

'ACRESCENTO NO ARQUIVO XML O NOVO ELEMENTO (NO)

servidores.appendChild(informacoesservidor)

 

'CRIAÇÃO DO NO NOME

Set nome = arquivoxml.CreateElement("nome")

 

'PASSAGEM DO VALOR DO BANCO PARA O NO

nome.text = reret("nome")

 

'ACRESCENTO NO ARQUIVO XML O NOVO ELEMENTO (NO)

informacoesservidor.AppendChild(nome)

 

'ESTE PROCEDIMENTO PODE SER FEITO PARA VARIOS NOS LEMBRANDO-SE DE CRIAR O NO PASSAR O VALOR DO BANCO E ADICIONAR O NO AO ARQUIVO.

 

reret.MoveNext

wend

 

 

'GRAVA AS INFORMAÇÕES NO CAMINHO DETERMINADO

arquivoxml.save ("c:\inetpub\wwwroot\reret\servidores.xml")

 

'LIBERADO O OBJETO

set arquivoxml=nothing

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.