Ola pessoal
como eu posso gerar um arquivo XML?
eu estudei o DOM para ler arquivos XML, mas gerar como eu faço??
valeu
Ola pessoal
como eu posso gerar um arquivo XML?
eu estudei o DOM para ler arquivos XML, mas gerar como eu faço??
valeu
ola,
XML nada mais é do que texto … você deve salva-lo usando um Writer mesmo (como qualquer arquivo). Sua API deve ter um método retornando o conteúdo XML como String (.toString()?)… veja a documentação.
As API de manipulação XML estão ai pra te ajudar a manipular (duh!) os nós, atributos, elementos, etc. etc. etc. facilitando o processamento dos dados XML.
A entrada do XML para a API (Sax, DOM, o que for) pode ser de várias maneiras, entre elas um arquivo mas não necessariamente … do mesmo modo a saída funciona.
[]s
xml um arquivo texto até ae tudo bem
se for pra gerar ele com FileWriter, PrintWriter beleza
mas provavelmente deve ter algo mais simples…
concluindo tudo que vc disse
existe um jeito de gerar os arquivos usando o proprio DOM entao?
aqui no guj soh mostra como recuperar as informações
e nao gerar
Sim, existe maneira de gerar um arquivo XML usando DOM.
Criar um documento vazio (eu adaptei o exemplo consultando o JavaDoc)
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument() ;
Escrever no disco (não é padrão, o Xerxes possui o recurso mas outras bibliotecas podem não ter).
[code]import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;
import org.apache.xml.serialize.LineSeparator;
…
OutputFormat format = new OutputFormat((Document)core);
format.setLineSeparator(LineSeparator.Windows);
format.setIndenting(true);
format.setLineWidth(0);
format.setPreserveSpace(true);
XMLSerializer serializer = new XMLSerializer (
new FileWriter(“output.xml”), format);
serializer.asDOMSerializer();
serializer.serialize(document);[/code]
[/url]
[i]Olá pessoal gerei um arquivo XML
bom eu vou deixar o codigo postado ai se alguem precisar
até abraços pessoal[/i]
package XML;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.ProcessingInstruction;
public class TransformaXML extends XML{
/**
* @throws IOException
*
*/
public static void main(String[] args)throws ParserConfigurationException,
TransformerConfigurationException,
TransformerException, IOException{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document document = db.newDocument();
Element book = document.createElement("diopsCadastral");
book.setAttribute("ct_identificadorMensagem" , "ct_diopsCadastralOdontMedGru");
document.appendChild(book);
Element chapter = document.createElement("ct_identificadorMensagem");
Element title = document.createElement("st_nome60");
title.appendChild(document.createTextNode("luiz"));
Element title1 = document.createElement("st_registroANS");
title1.appendChild(document.createTextNode("135165151651"));
Element title2 = document.createElement("st_cnpj");
title2.appendChild(document.createTextNode("358.971.328-36"));
Element title3 = document.createElement("date");
title3.appendChild(document.createTextNode("12/11/88"));
Element title4 = document.createElement("st_transacao");
title4.appendChild(document.createTextNode("NULL"));
Element title5 = document.createElement("string");
title5.appendChild(document.createTextNode("NULL"));
Element title6 = document.createElement("ct_diopsCadastralOdontMedGru");
title6.appendChild(document.createTextNode("NULL"));
Element title7 = document.createElement("ct_cadastro");
title7.appendChild(document.createTextNode("NULL"));
Element title8 = document.createElement("st_nome60");
title8.appendChild(document.createTextNode("NULL"));
Element title9 = document.createElement("ct_enderecoDiops");
title9.appendChild(document.createTextNode("NULL"));
Element title10 = document.createElement("st_logradouroDiops");
title10.appendChild(document.createTextNode("NULL"));
Element title11 = document.createElement("st_numLogradouroDiops");
title11.appendChild(document.createTextNode("NULL"));
Element title12 = document.createElement("st_descricao20");
title12.appendChild(document.createTextNode("NULL"));
Element title13 = document.createElement("st_descricao20");
title13.appendChild(document.createTextNode("NULL"));
Element title14 = document.createElement("st_codigoMunicipioIBGE");
title14.appendChild(document.createTextNode("NULL"));
Element title15 = document.createElement("st_UF");
title15.appendChild(document.createTextNode("NULL"));
Element title16 = document.createElement("st_CEP");
title16.appendChild(document.createTextNode("NULL"));
Element title17 = document.createElement("ct_telefone");
title17.appendChild(document.createTextNode("NULL"));
Element title18 = document.createElement("st_codigoDDI");
title18.appendChild(document.createTextNode("NULL"));
Element title19 = document.createElement("st_numeroTel");
title19.appendChild(document.createTextNode("NULL"));
Element title20 = document.createElement("st_numeroRamal");
title20.appendChild(document.createTextNode("NULL"));
Element title21 = document.createElement("ct_telefone");
title21.appendChild(document.createTextNode("NULL"));
Element title22 = document.createElement("st_codigoDDI");
title22.appendChild(document.createTextNode("NULL"));
Element title23 = document.createElement("st_codigoDDI");
title23.appendChild(document.createTextNode("NULL"));
Element title24 = document.createElement("st_codigoDDI");
title24.appendChild(document.createTextNode("NULL"));
Element title25 = document.createElement("st_codigoDDI");
title25.appendChild(document.createTextNode("NULL"));
Element title26 = document.createElement("st_codigoDDI");
title26.appendChild(document.createTextNode("NULL"));
Element title27 = document.createElement("st_codigoDDI");
title27.appendChild(document.createTextNode("NULL"));
Element title28 = document.createElement("st_codigoDDI");
title28.appendChild(document.createTextNode("NULL"));
Element title29 = document.createElement("st_codigoDDI");
title29.appendChild(document.createTextNode("NULL"));
Element title30 = document.createElement("st_codigoDDI");
title30.appendChild(document.createTextNode("NULL"));
Element title31 = document.createElement("st_codigoDDI");
title31.appendChild(document.createTextNode("NULL"));
Element title32 = document.createElement("st_codigoDDI");
title32.appendChild(document.createTextNode("NULL"));
Element title33 = document.createElement("st_codigoDDI");
title33.appendChild(document.createTextNode("NULL"));
Element title34 = document.createElement("st_codigoDDI");
title34.appendChild(document.createTextNode("NULL"));
Element title35 = document.createElement("st_codigoDDI");
title35.appendChild(document.createTextNode("NULL"));
Element title36 = document.createElement("st_codigoDDI");
title36.appendChild(document.createTextNode("NULL"));
Element title37 = document.createElement("st_codigoDDI");
title37.appendChild(document.createTextNode("NULL"));
Element title38 = document.createElement("st_codigoDDI");
title38.appendChild(document.createTextNode("NULL"));
Element title39 = document.createElement("st_codigoDDI");
title39.appendChild(document.createTextNode("NULL"));
Element title40 = document.createElement("st_codigoDDI");
title40.appendChild(document.createTextNode("NULL"));
Element title41 = document.createElement("st_codigoDDI");
title41.appendChild(document.createTextNode("NULL"));
Element title42 = document.createElement("st_codigoDDI");
title42.appendChild(document.createTextNode("NULL"));
Element title43 = document.createElement("st_codigoDDI");
title43.appendChild(document.createTextNode("NULL"));
Element title44 = document.createElement("st_codigoDDI");
title44.appendChild(document.createTextNode("NULL"));
Element title45 = document.createElement("st_codigoDDI");
title45.appendChild(document.createTextNode("NULL"));
Element title46 = document.createElement("st_codigoDDI");
title46.appendChild(document.createTextNode("NULL"));
Element title47 = document.createElement("st_codigoDDI");
title47.appendChild(document.createTextNode("NULL"));
Element title48 = document.createElement("st_codigoDDI");
title48.appendChild(document.createTextNode("NULL"));
Element title49 = document.createElement("st_codigoDDI");
title49.appendChild(document.createTextNode("NULL"));
Element title50 = document.createElement("st_codigoDDI");
title50.appendChild(document.createTextNode("NULL"));
Element title51 = document.createElement("st_codigoDDI");
title51.appendChild(document.createTextNode("NULL"));
Element title52 = document.createElement("st_codigoDDI");
title52.appendChild(document.createTextNode("NULL"));
Element title53 = document.createElement("st_codigoDDI");
title53.appendChild(document.createTextNode("NULL"));
Element title54 = document.createElement("st_codigoDDI");
title54.appendChild(document.createTextNode("NULL"));
Element title55 = document.createElement("st_codigoDDI");
title55.appendChild(document.createTextNode("NULL"));
Element title56 = document.createElement("st_codigoDDI");
title56.appendChild(document.createTextNode("NULL"));
Element title57 = document.createElement("st_codigoDDI");
title57.appendChild(document.createTextNode("NULL"));
Element title58 = document.createElement("st_codigoDDI");
title58.appendChild(document.createTextNode("NULL"));
Element title59 = document.createElement("st_codigoDDI");
title59.appendChild(document.createTextNode("NULL"));
Element title60 = document.createElement("st_codigoDDI");
title60.appendChild(document.createTextNode("NULL"));
Element title61 = document.createElement("st_codigoDDI");
title61.appendChild(document.createTextNode("NULL"));
Element title62 = document.createElement("st_codigoDDI");
title62.appendChild(document.createTextNode("NULL"));
Element title63 = document.createElement("st_codigoDDI");
title63.appendChild(document.createTextNode("NULL"));
Element title64 = document.createElement("st_codigoDDI");
title64.appendChild(document.createTextNode("NULL"));
Element title65 = document.createElement("st_codigoDDI");
title65.appendChild(document.createTextNode("NULL"));
Element title66 = document.createElement("st_codigoDDI");
title66.appendChild(document.createTextNode("NULL"));
Element title67 = document.createElement("st_codigoDDI");
title67.appendChild(document.createTextNode("NULL"));
Element title68 = document.createElement("st_codigoDDI");
title68.appendChild(document.createTextNode("NULL"));
Element title69 = document.createElement("st_codigoDDI");
title69.appendChild(document.createTextNode("NULL"));
Element title70 = document.createElement("st_codigoDDI");
title70.appendChild(document.createTextNode("NULL"));
Element title71 = document.createElement("st_codigoDDI");
title71.appendChild(document.createTextNode("NULL"));
Element title72 = document.createElement("st_codigoDDI");
title72.appendChild(document.createTextNode("NULL"));
Element title73 = document.createElement("st_codigoDDI");
title73.appendChild(document.createTextNode("NULL"));
Element title74 = document.createElement("st_codigoDDI");
title74.appendChild(document.createTextNode("NULL"));
Element title75 = document.createElement("st_codigoDDI");
title75.appendChild(document.createTextNode("NULL"));
Element title76 = document.createElement("st_codigoDDI");
title76.appendChild(document.createTextNode("NULL"));
Element title77 = document.createElement("st_codigoDDI");
title77.appendChild(document.createTextNode("NULL"));
Element title78 = document.createElement("st_codigoDDI");
title78.appendChild(document.createTextNode("NULL"));
Element title79 = document.createElement("st_codigoDDI");
title79.appendChild(document.createTextNode("NULL"));
Element title80 = document.createElement("st_codigoDDI");
title80.appendChild(document.createTextNode("NULL"));
Element title81 = document.createElement("st_codigoDDI");
title81.appendChild(document.createTextNode("NULL"));
Element title82 = document.createElement("st_codigoDDI");
title82.appendChild(document.createTextNode("NULL"));
Element title83 = document.createElement("st_codigoDDI");
title83.appendChild(document.createTextNode("NULL"));
Element title84 = document.createElement("st_codigoDDI");
title84.appendChild(document.createTextNode("NULL"));
Element title85 = document.createElement("st_codigoDDI");
title85.appendChild(document.createTextNode("NULL"));
Element title86 = document.createElement("st_codigoDDI");
title86.appendChild(document.createTextNode("NULL"));
Element title87 = document.createElement("st_codigoDDI");
title87.appendChild(document.createTextNode("NULL"));
Element title88 = document.createElement("st_codigoDDI");
title88.appendChild(document.createTextNode("NULL"));
Element title89 = document.createElement("st_codigoDDI");
title89.appendChild(document.createTextNode("NULL"));
Element title90 = document.createElement("st_codigoDDI");
title90.appendChild(document.createTextNode("NULL"));
Element title91 = document.createElement("st_codigoDDI");
title91.appendChild(document.createTextNode("NULL"));
Element title92 = document.createElement("st_codigoDDI");
title92.appendChild(document.createTextNode("NULL"));
Element title93 = document.createElement("st_codigoDDI");
title93.appendChild(document.createTextNode("NULL"));
Element title94 = document.createElement("st_codigoDDI");
title94.appendChild(document.createTextNode("NULL"));
Element title95 = document.createElement("st_codigoDDI");
title95.appendChild(document.createTextNode("NULL"));
Element title96 = document.createElement("st_codigoDDI");
title96.appendChild(document.createTextNode("NULL"));
Element title97 = document.createElement("st_codigoDDI");
title97.appendChild(document.createTextNode("NULL"));
Element title98 = document.createElement("st_codigoDDI");
title98.appendChild(document.createTextNode("NULL"));
Element title99 = document.createElement("st_codigoDDI");
title99.appendChild(document.createTextNode("NULL"));
Element title100 = document.createElement("st_codigoDDI");
title100.appendChild(document.createTextNode("NULL"));
Element title101 = document.createElement("st_codigoDDI");
title101.appendChild(document.createTextNode("NULL"));
Element title102 = document.createElement("st_codigoDDI");
title102.appendChild(document.createTextNode("NULL"));
Element title103 = document.createElement("st_codigoDDI");
title103.appendChild(document.createTextNode("NULL"));
Element title104 = document.createElement("st_codigoDDI");
title104.appendChild(document.createTextNode("NULL"));
Element title105 = document.createElement("st_codigoDDI");
title105.appendChild(document.createTextNode("NULL"));
Element title106 = document.createElement("st_codigoDDI");
title106.appendChild(document.createTextNode("NULL"));
Element title107 = document.createElement("st_codigoDDI");
title107.appendChild(document.createTextNode("NULL"));
Element title108 = document.createElement("st_codigoDDI");
title108.appendChild(document.createTextNode("NULL"));
Element title109 = document.createElement("st_codigoDDI");
title109.appendChild(document.createTextNode("NULL"));
Element title110 = document.createElement("st_codigoDDI");
title110.appendChild(document.createTextNode("NULL"));
Element title111 = document.createElement("st_codigoDDI");
title111.appendChild(document.createTextNode("NULL"));
Element title112 = document.createElement("st_codigoDDI");
title112.appendChild(document.createTextNode("NULL"));
Element title113 = document.createElement("st_codigoDDI");
title113.appendChild(document.createTextNode("NULL"));
Element title114 = document.createElement("st_codigoDDI");
title114.appendChild(document.createTextNode("NULL"));
Element title115 = document.createElement("st_codigoDDI");
title115.appendChild(document.createTextNode("NULL"));
Element title116 = document.createElement("st_codigoDDI");
title116.appendChild(document.createTextNode("NULL"));
Element title117 = document.createElement("st_codigoDDI");
title117.appendChild(document.createTextNode("NULL"));
Element title118 = document.createElement("st_codigoDDI");
title118.appendChild(document.createTextNode("NULL"));
Element title119 = document.createElement("st_codigoDDI");
title119.appendChild(document.createTextNode("NULL"));
Element title120 = document.createElement("st_codigoDDI");
title120.appendChild(document.createTextNode("NULL"));
Element title121 = document.createElement("st_codigoDDI");
title121.appendChild(document.createTextNode("NULL"));
Element title122 = document.createElement("st_codigoDDI");
title122.appendChild(document.createTextNode("NULL"));
Element title123 = document.createElement("st_codigoDDI");
title123.appendChild(document.createTextNode("NULL"));
Element title124 = document.createElement("st_codigoDDI");
title124.appendChild(document.createTextNode("NULL"));
Element title125 = document.createElement("st_codigoDDI");
title125.appendChild(document.createTextNode("NULL"));
Element title126 = document.createElement("st_codigoDDI");
title126.appendChild(document.createTextNode("NULL"));
Element title127 = document.createElement("st_codigoDDI");
title127.appendChild(document.createTextNode("NULL"));
Element title128 = document.createElement("st_codigoDDI");
title128.appendChild(document.createTextNode("NULL"));
Element title129 = document.createElement("st_codigoDDI");
title129.appendChild(document.createTextNode("NULL"));
Element title130 = document.createElement("st_codigoDDI");
title130.appendChild(document.createTextNode("NULL"));
Element title131 = document.createElement("st_codigoDDI");
title131.appendChild(document.createTextNode("NULL"));
Element title132 = document.createElement("st_codigoDDI");
title132.appendChild(document.createTextNode("NULL"));
Element title133 = document.createElement("st_codigoDDI");
title133.appendChild(document.createTextNode("NULL"));
Element title134 = document.createElement("st_codigoDDI");
title134.appendChild(document.createTextNode("NULL"));
Element title135 = document.createElement("st_codigoDDI");
title135.appendChild(document.createTextNode("NULL"));
Element title136 = document.createElement("st_codigoDDI");
title136.appendChild(document.createTextNode("NULL"));
Element title137 = document.createElement("st_codigoDDI");
title137.appendChild(document.createTextNode("NULL"));
Element title138 = document.createElement("st_codigoDDI");
title138.appendChild(document.createTextNode("NULL"));
Element title139 = document.createElement("st_codigoDDI");
title139.appendChild(document.createTextNode("NULL"));
Element title140 = document.createElement("st_codigoDDI");
title140.appendChild(document.createTextNode("NULL"));
Element title141 = document.createElement("st_codigoDDI");
title141.appendChild(document.createTextNode("NULL"));
Element title142 = document.createElement("st_codigoDDI");
title142.appendChild(document.createTextNode("NULL"));
Element title143 = document.createElement("st_codigoDDI");
title143.appendChild(document.createTextNode("NULL"));
Element title144 = document.createElement("st_codigoDDI");
title144.appendChild(document.createTextNode("NULL"));
Element title145 = document.createElement("st_codigoDDI");
title145.appendChild(document.createTextNode("NULL"));
Element title146 = document.createElement("st_codigoDDI");
title146.appendChild(document.createTextNode("NULL"));
Element title147 = document.createElement("st_codigoDDI");
title147.appendChild(document.createTextNode("NULL"));
Element title148 = document.createElement("st_codigoDDI");
title148.appendChild(document.createTextNode("NULL"));
Element title149 = document.createElement("st_codigoDDI");
title149.appendChild(document.createTextNode("NULL"));
chapter.appendChild(title1);
chapter.appendChild(title2);
chapter.appendChild(title3);
chapter.appendChild(title4);
chapter.appendChild(title5);
chapter.appendChild(title6);
chapter.appendChild(title7);
chapter.appendChild(title8);
chapter.appendChild(title9);
chapter.appendChild(title10);
chapter.appendChild(title11);
chapter.appendChild(title12);
chapter.appendChild(title13);
chapter.appendChild(title14);
chapter.appendChild(title15);
chapter.appendChild(title16);
chapter.appendChild(title17);
chapter.appendChild(title18);
chapter.appendChild(title19);
chapter.appendChild(title20);
chapter.appendChild(title21);
chapter.appendChild(title22);
chapter.appendChild(title23);
chapter.appendChild(title24);
chapter.appendChild(title25);
chapter.appendChild(title26);
chapter.appendChild(title27);
chapter.appendChild(title28);
chapter.appendChild(title29);
chapter.appendChild(title30);
chapter.appendChild(title31);
chapter.appendChild(title32);
chapter.appendChild(title33);
chapter.appendChild(title34);
chapter.appendChild(title35);
chapter.appendChild(title36);
chapter.appendChild(title37);
chapter.appendChild(title38);
chapter.appendChild(title39);
chapter.appendChild(title40);
chapter.appendChild(title41);
chapter.appendChild(title42);
chapter.appendChild(title43);
chapter.appendChild(title44);
chapter.appendChild(title45);
chapter.appendChild(title46);
chapter.appendChild(title47);
chapter.appendChild(title48);
chapter.appendChild(title49);
chapter.appendChild(title50);
chapter.appendChild(title51);
chapter.appendChild(title52);
chapter.appendChild(title53);
chapter.appendChild(title54);
chapter.appendChild(title55);
chapter.appendChild(title56);
chapter.appendChild(title57);
chapter.appendChild(title58);
chapter.appendChild(title59);
chapter.appendChild(title60);
chapter.appendChild(title61);
chapter.appendChild(title62);
chapter.appendChild(title63);
chapter.appendChild(title64);
chapter.appendChild(title65);
chapter.appendChild(title66);
chapter.appendChild(title67);
chapter.appendChild(title68);
chapter.appendChild(title69);
chapter.appendChild(title70);
chapter.appendChild(title71);
chapter.appendChild(title72);
chapter.appendChild(title73);
chapter.appendChild(title74);
chapter.appendChild(title75);
chapter.appendChild(title76);
chapter.appendChild(title77);
chapter.appendChild(title78);
chapter.appendChild(title79);
chapter.appendChild(title80);
chapter.appendChild(title81);
chapter.appendChild(title82);
chapter.appendChild(title83);
chapter.appendChild(title84);
chapter.appendChild(title85);
chapter.appendChild(title86);
chapter.appendChild(title87);
chapter.appendChild(title88);
chapter.appendChild(title89);
chapter.appendChild(title90);
chapter.appendChild(title91);
chapter.appendChild(title92);
chapter.appendChild(title93);
chapter.appendChild(title94);
chapter.appendChild(title95);
chapter.appendChild(title96);
chapter.appendChild(title97);
chapter.appendChild(title98);
chapter.appendChild(title99);
chapter.appendChild(title100);
chapter.appendChild(title101);
chapter.appendChild(title102);
chapter.appendChild(title103);
chapter.appendChild(title104);
chapter.appendChild(title105);
chapter.appendChild(title106);
chapter.appendChild(title107);
chapter.appendChild(title108);
chapter.appendChild(title109);
chapter.appendChild(title110);
chapter.appendChild(title111);
chapter.appendChild(title112);
chapter.appendChild(title113);
chapter.appendChild(title114);
chapter.appendChild(title115);
chapter.appendChild(title116);
chapter.appendChild(title117);
chapter.appendChild(title118);
chapter.appendChild(title119);
chapter.appendChild(title120);
chapter.appendChild(title121);
chapter.appendChild(title122);
chapter.appendChild(title123);
chapter.appendChild(title124);
chapter.appendChild(title125);
chapter.appendChild(title126);
chapter.appendChild(title127);
chapter.appendChild(title128);
chapter.appendChild(title129);
chapter.appendChild(title130);
chapter.appendChild(title131);
chapter.appendChild(title132);
chapter.appendChild(title133);
chapter.appendChild(title134);
chapter.appendChild(title135);
chapter.appendChild(title136);
chapter.appendChild(title137);
chapter.appendChild(title138);
chapter.appendChild(title139);
chapter.appendChild(title141);
chapter.appendChild(title142);
chapter.appendChild(title143);
chapter.appendChild(title144);
chapter.appendChild(title145);
chapter.appendChild(title146);
chapter.appendChild(title147);
chapter.appendChild(title148);
chapter.appendChild(title149);
book.appendChild(chapter);
/**PROCESSO PARA GERAR UM ENCODING DE ISO 8859-1
* ProcessingInstruction prcProcesso =
* document.createProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'");
* document.appendChild(prcProcesso);
*/
TransformerFactory tf = TransformerFactory.newInstance();
Transformer xformer = tf.newTransformer();
xformer.setOutputProperty(OutputKeys.METHOD, "xml");
xformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
//ESSE CODIGO IMPRIME NA TELA A GERAÇÃO DO XML
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(System.out);
xformer.transform(source,result);
/**
try{
xformer.transform(new DOMSource(document), new StreamResult(new FileWriter(new File("c:/teste.xml"))));
DOMSource source = new DOMSource(document);
System.out.println("ARQUIVO GERADO COM SUCESSO!!!");
}
catch(Exception ex){
ex.printStackTrace();
System.out.println("OCORREU UM ERRO NA GRAVAÇÃO"+ex);
}*/
}
}
Quanta coisa!!!
Faça como nosso amigo aí lhe indicou XSTREAM!!!
Aqui no GUJ tem alguns posts meus tratando deste assunto. Tive algumas dificuldades, postei as soluções e vai poder verificar que é moleza!
Qualquer coisa estamos por aí!
Marco A.
[b][i]Bom eu estava fazendo com XStream mais nao estava dando muito certo a partir para a parte de DOM
que o pessoal fala que o carregamento é na memoria, bom eu nao tive problema com issso…
o tamanho depende de quantos elementos seu XML vai ter…
você pode ter apenas tres linhas…mais tbm pode ter mais…
o codigo que eu postei está bom correto com as bibliotecas e tudo
tira uma parte dos elementos que claro ira ficar menor
mas como esse é para uma empresa tinha quer ser desse tamanho mesmo
XD…
bom até mais
[/b][/i]