XML压缩在线工具
关于XML压缩在线工具:
这个XML压缩在线工具可以帮助您压缩原始XML字符串,可以节省空间,以便更快地在网络中传输.
更多关于XML的链接 (Extensible Markup Language):
RFC 3470 (XML): https://tools.ietf.org/html/rfc3470
Python中的XML (BeautifulSoup): https://www.crummy.com/software/BeautifulSoup/
Java中的XML (dom4j): https://dom4j.github.io/
用Python压缩XML字符串 (用 package htmlmin):
from htmlmin.minify import html_minify def xml_minify(xml_str): xml_str = html_minify(xml_str, parser="lxml") return xml_str
用Java压缩XML字符串 (用 package dom4j):
import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; public String minify(String xmlStr){ Document document=DocumentHelper.parseText(xmlStr); OutputFormat format=OutputFormat.createPrettyPrint(); StringWriter stringWriter=new StringWriter(); XMLWriter writer=new XMLWriter(stringWriter,format); writer.write(document); String resultStr=stringWriter.toString(); return resultStr; }