Alat online kompresi XML



TentangAlat online kompresi XML:

Alat online kompresi XML ini membantu Anda mengompresi string XML mentah, menghemat ruang untuk transfer lebih cepat melalui jaringan.

comic xml minifier

Lebih banyak tautan ke XML (Extensible Markup Language):

RFC 3470 (XML): https://tools.ietf.org/html/rfc3470

XML dalam Python (BeautifulSoup): https://www.crummy.com/software/BeautifulSoup/

XML dalam Java (dom4j): https://dom4j.github.io/

Kompres string XML dengan Python (dengan paket htmlmin):

  1. from htmlmin.minify import html_minify
  2.  
  3.  
  4. def xml_minify(xml_str):
  5. xml_str = html_minify(xml_str, parser="lxml")
  6. return xml_str

Kompres string XML di Jawa (dengan paket dom4j):

  1. import org.dom4j.Document;
  2. import org.dom4j.DocumentHelper;
  3. import org.dom4j.io.OutputFormat;
  4. import org.dom4j.io.XMLWriter;
  5.  
  6. public String minify(String xmlStr){
  7. Document document=DocumentHelper.parseText(xmlStr);
  8. OutputFormat format=OutputFormat.createPrettyPrint();
  9. StringWriter stringWriter=new StringWriter();
  10. XMLWriter writer=new XMLWriter(stringWriter,format);
  11. writer.write(document);
  12. String resultStr=stringWriter.toString();
  13. return resultStr;
  14. }