`
sunxboy
  • 浏览: 2878227 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

jixb 使用

XML 
阅读更多

1.unmarshal from file

"input.xml" -> Object

            // unmarshal customer information from file
            IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
            IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
            FileInputStream in = new FileInputStream("input.xml");
            Order order = (Order)uctx.unmarshalDocument(in, null);

 

2.marshal object to file

Object -> "out.xml"

 // marshal object back out to file (with nice indentation, as UTF-8)
            IMarshallingContext mctx = bfact.createMarshallingContext();
            mctx.setIndent(2);
            FileOutputStream out = new FileOutputStream("out.xml");
            mctx.setOutput(out, null);
            mctx.marshalDocument(order);

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics