What are the relative advantages of XMLEncoder and XStream?

后端 未结 8 2213
余生分开走
余生分开走 2021-02-06 13:12

Suppose I want to store many small configuration objects in XML, and I don\'t care too much about the format. The XMLDecoder class built into the JDK would work, and from what I

8条回答
  •  灰色年华
    2021-02-06 13:34

    Addition to @jay answer with example:

    Code:

    PortfolioAlternateIdentifier identifier = new PortfolioAlternateIdentifier();
    identifier.setEffectiveDate(new Date());
    identifier.setSchemeCode("AAA");
    identifier.setIdentifier("123456");
    

    The output using XStream:

    
     2014-05-02 20:14:15.961 IST
     AAA
     123456
       
    

    The output using XMLEncoder:

     
      
        
         
       
       1399041855961 
       
         
      
      123456 
      
        
        AAA 
        
       
     
    

提交回复
热议问题