Outil en ligne de compression XML



À propos deOutil en ligne de compression XML:

Cet outil en ligne de compression XML vous aide à compresser des chaînes XML brutes et à économiser de l'espace pour un transfert plus rapide sur le réseau.

comic xml minifier

Plus de liens vers XML (Extensible Markup Language):

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

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

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

Compresser les chaînes XML en Python (avec le package 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

Compresser les chaînes XML en Java (avec le package 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. }