我正在使用本教程编写一个 XML 文件。我申请了
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "4");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
xml格式化代码。
但是对于长 xml 数据,它向我显示 xml 像 khis:
<kml>
<Placemark>
<name>yong</name>
<Polygon>
<timezone>EASTERN</timezone>
<outerBoundaryIs>
<LinearRing>
<coordinates>-77.05788457660967,38.87253259892824,100
-77.05465973756702,38.87291016281703,100
-77.05315536854791,38.87053267794386,100
-77.05552622493516,38.868757801256,100
-77.05844056290393,38.86996206506943,100
-77.05788457660967,38.87253259892824,100</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</kml>
但我想按以下方式格式化:
<kml>
<Placemark>
<name>yong</name>
<Polygon>
<timezone>EASTERN</timezone>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-77.05788457660967,38.87253259892824,100
-77.05465973756702,38.87291016281703,100
-77.05315536854791,38.87053267794386,100
-77.05552622493516,38.868757801256,100
-77.05844056290393,38.86996206506943,100
-77.05788457660967,38.87253259892824,100
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</kml>
这个怎么做?这种格式的变压器有什么方法或其他属性可以实现吗?提前致谢..