commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nuno Miguel Ferreira" <Nuno.MFerre...@siemens.com>
Subject [ECS] Format a XML Document
Date Thu, 24 Feb 2005 15:25:58 GMT
 I there ... I started using the ECS API today and this is really what I
need ... I only whish to know only little thing. Is it possible to
insert line breaks to format the XML document in a more readable way?

 Im using this example code ...

public class JakartaECSExample {

    public static void main(String[] args){
        XML root = new XML("root");
        root.addXMLAttribute("attr", "root");

        
        XML innerElement = new XML("element");
        root.addElement(innerElement);
        
        XMLDocument doc = new XMLDocument();
        doc.addElement(root);
        System.out.println(doc.toString());
        
        try{
            File file = new File ("d:/TMP/xmldoc.xml");
            OutputStream out = new FileOutputStream(file);
            
            doc.output(out);
            
            out.flush();
            out.close();
            
            
        }catch(FileNotFoundException e){
            e.printStackTrace();
            
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}

 The generated output is like this:
 <?xml version="1.0" standalone="yes"?><root
attr='raiz'><element></element></root>

 Is there any possibility to include linebreaks after each xml tag? I
searched the API documentation and I've found a getNeedLineBreak() but
no set method ... 

 Help ... :)

 Thks in advance ...

 Nuno Belo
-------------------------------------------- 
 Siemens, S.A. 
 COM RD1 WON NM P3 
 Software Development - TMN Porto 
 Estrada Nacional 107, 3570
 4456-901 Perafita
-------------------------------------------- 
 Tel.: + 351 22 999 2073
 Fax: + 351 22 999 2080
 Email: nuno.mferreira@siemens.com
-------------------------------------------- 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message