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; }