在xml序列化期间将每个属性放在新行上 [英] Putting each attribute on a new line during xml serialization

查看:123
本文介绍了在xml序列化期间将每个属性放在新行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个DOM对象(或包含xml的字符串)。是否有可能以某种方式序列化xml,使每个属性出现在新行上?

Lets say I have a DOM object (or a string containing xml). Is it in any way possible to serialize the xml in such a way that each attribute appears on a new line?

这是我想要的输出:

<parent>
    <anElement 
        attrOne="1"
        attrTwo="2"
        attrThree="3"
    />
</parent>

首选如果解决方案是标准java api的一部分,但我怀疑这样的功能不可用在那里,或者我错了?

Preferred if the solution a part of the standard java api, but I suspect such a feature is not available in there, or am I wrong?

我在.NET Framework中找到了一个序列化程序的属性,名为 NewLineOnAttributes 。我正在寻找的东西是等价的,但在java中。

I found a property for a serializer in the .NET Framework, called NewLineOnAttributes. What I am searching for is something equivalent, but in java.

推荐答案

DecentXML 解析器可以执行此操作。

The DecentXML parser can do this.

这篇关于在xml序列化期间将每个属性放在新行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆