在Java中创建XML文件的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-25 05:25:37
本文介绍了在Java中创建XML文件的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们目前正在使用dom4j来创建XML文件。但是,我猜现在有更好的东西了。如果我们是Java 1.6或更高版本,那么在写出XML文件时使用的最好(运行时最快,使用简单)类。

We are presently using dom4j to create XML files. However, I'm guessing there's something better now. If we are Java 1.6 or later, what is the best (fastest when running, simple to use) class(es) to use when writing out an XML file.

I不需要构建DOM然后编写整个DOM。我只需要在将它们传递给类时写出元素/属性的东西。

I do not need to build a DOM and then write the entire DOM. I just need something that will write out the elements/attributes as I pass them to the class.

谢谢 - 戴夫

推荐答案

如果您只想编写一个XML文档,可以精确控制元素,属性和其他文档组件的创建,您可以使用 XMLStreamWriter 。

If you just want to write an XML document having exact control over the creating of elements, attributes and other document components, you may use the XMLStreamWriter from the StAX API.

更多推荐

在Java中创建XML文件的最佳方法是什么?

本文发布于:2023-11-28 06:38:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641324.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   方法   Java   XML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!