欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jixb 使用

程序员文章站 2022-01-20 10:05:29
...

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);

 

 

相关标签: XML