我有一个 xml,其中包含项目列表中的一些文本块。这些项目包含一些格式化的文本。它在新行之前使用换行符和空格进行格式化(我的 IDE 的标准格式)。例如:
<items>
<item>
<title>Long text Item</title>
<content>
Some long long long text that I
want to format using line brakes
so that it will be more readable
in source code.
</content>
</item>
...
<items>
我使用以下代码阅读了 XML:
XmlMapper mapper = new XmlMapper();
List<ItemDTO> result = mapper.readValue(
inputStream, new TypeReference<List<ItemDTO>>() {}
);
问题:这样的解析保留了content
元素内部的线闸和间距。
问题:如何解析 XML 忽略content
元素中的间距和换行符?