使用xls去掉XML多余的空格和换行
Use an XSL transformation with the xsl:strip-space instruction.
?
?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template></xsl:stylesheet>
?
TransformerFactory factory = TransformerFactory.newInstance();Transformer transformer = factory.newTransformer( new StreamSource("strip-space.xsl"));DOMSource source = new DOMSource(document);StreamResult result = new StreamResult(System.out); transformer.transform(source, result);?
?