我正在使用 Jaxb Marshaller 将 java 对象转换为 xml,并将 Marshaller.JAXB_FORMATTED_OUTPUT 设置为 true。这给了我以下格式的 xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xml>
<time>20210716124226</time>
<details>
<employee id="100" time="20210716124212">
<name>asd</name>
<empid>1</empid>
<jobCategory>Contract</jobCategory>
</employee>
<employee id="102" time="20210716124212">
<name>ative</name>
<empid>2</empid>
<jobCategory>Permanent</jobCategory>
</employee>
</details>
</xml>
但要求是生成以下格式的 xml,没有缩进:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xml>
<time>20210716124226</time>
<details>
<employee id="100" time="20210716124212"><name>xyz</name><empid>1</empid><jobCategory>Contract</jobCategory></employee>
<employee id="102" time="20210716124212"><name>abc</name><empid>2</empid><jobCategory>Permanent</jobCategory></employee>
</details>
</xml>
我如何使用 java 实现这个结果?