【发布时间】:2014-02-12 10:47:44
【问题描述】:
请帮助使用 apache axiom 生成 xml 文件,任何带有一个父标签和两个子标签的 xml 文件,我尝试了以下代码
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns1 = factory.createOMNamespace("bar","x");
OMElement root = factory.createOMElement("root",ns1);
OMNamespace ns2 = root.declareNamespace("bar1","y");
OMElement elt1 = factory.createOMElement("foo",ns1);
OMElement elt2 = factory.createOMElement("yuck",ns2);
OMText txt1 = factory.createOMText(elt2,"blah");
elt2.addChild(txt1);
elt1.addChild(elt2);
root.addChild(elt1);
请帮助我如何序列化根元素,其中 OMElment 是非序列化 api 类。 请帮我举个例子。
【问题讨论】: