首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

AXIOM的引见与使用

2012-12-28 
AXIOM的介绍与使用什么是AXIOM?Axiom ,也就是Axis Object Model,Apache下一款XML对象模型?OutputStream os

AXIOM的介绍与使用
什么是AXIOM?

Axiom ,也就是Axis Object Model,Apache下一款XML对象模型

?
OutputStream os = new FileOutputStream("D:/test.xml");XMLStreamWriter streamWriter = XMLOutputFactory.newFactory().createXMLStreamWriter(os);//获取对象模型工厂类(元素都是通过该工厂创建)OMFactory factory = OMAbstractFactory.getOMFactory();//通过工厂创建一个文档对象OMDocument document = factory.createOMDocument();//通过工厂创建一个root节点元素OMElement rootElement = factory.createOMElement(new QName("root"));OMElement personElement = factory.createOMElement(new QName("person"));//给节点元素添加文本内容personElement.addChild(factory.createOMText("测试"));//给节点添加属性personElement.addAttribute(factory.createOMAttribute("id", null, "101"));//节点元素添加到根节点下rootElement.addChild(personElement);//将根节点添加到文档中document.addChild(rootElement);//序列化文档对象到输出流中document.serialize(streamWriter);streamWriter.flush();streamWriter.close();
?转http://blog.sina.com.cn/s/blog_6974144701012lud.html

热点排行