When using Nim's xmltree module for the first time, I encountered the following peculiarities:
xmltree's $() method [line numbers refer to the resulting XML document]
Also, it has not way to
It would be nice to be able to influence $()'s behavior and have a more "beautified" rsp. consistent output (especially given the fact, that this module is a part of the standard library).
Sample prog
import xmlparser, xmltree
var
   outFile: File
   errors:  seq[string] = @[]
   
   xml = loadXml("blocklist.xml", errors)
if open(outFile, "xmltest.xml", fmWrite):
   outFile.write($xml)
   outFile.close()
Sample input file (extracts from Mozilla's blocklist.xml):
<?xml version="1.0"?>
<blocklist xmlns="http://www.mozilla.org/2006/addons-blocklist" lastupdate="1469801851000">
   <emItems>
      <emItem  blockID="i45" id="{22119944-ED35-4ab1-910B-E619EA06A115}">
      <versionRange  minVersion="0.1" maxVersion="7.6.1">
      <targetApplication  id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
      <versionRange  minVersion="8.0a1" maxVersion="*" />
      </targetApplication>
      </versionRange>
      <prefs></prefs>
      </emItem>
      
      <emItem  blockID="i506" id="/^ext@bettersurfplus/">
      <versionRange  minVersion="0" maxVersion="*" severity="3"></versionRange>
      <prefs></prefs>
      </emItem>
      
      <emItem  blockID="i1119" id="/^([email protected]|[email protected]|[email protected]|[email protected])$/">
      <versionRange  minVersion="0" maxVersion="*" severity="3"></versionRange>
      <prefs></prefs>
      </emItem>
   </emItems>
   
   <pluginItems>
      <pluginItem  blockID="p26">
      <match name="name" exp="^Yahoo Application State Plugin$" /><match name="description" exp="^Yahoo Application State Plugin$" /><match name="filename" exp="npYState.dll" /><versionRange >
      <targetApplication  id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
      <versionRange  minVersion="3.0a1" maxVersion="3.*" />
      </targetApplication>
      </versionRange>
      </pluginItem>
   </pluginItems>
   
   <gfxItems>
      <gfxBlacklistEntry  blockID="g35"><os>WINNT 6.1</os><vendor>0x10de</vendor><devices>
      <device>0x0a6c</device>
      </devices>
      <feature>DIRECT2D</feature><featureStatus>BLOCKED_DRIVER_VERSION</featureStatus><driverVersion>8.17.12.5896</driverVersion><driverVersionComparator>LESS_THAN_OR_EQUAL</driverVersionComparator></gfxBlacklistEntry>
      
      <gfxBlacklistEntry  blockID="g1072"><os>All</os><vendor>0x8086</vendor><devices>
      <device>0x2a42</device>
      <device>0x2e22</device>
      <device>0x2e12</device>
      <device>0x2e32</device>
      <device>0x0046</device>
      </devices>
      <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus><driverVersion>8.15.10.1892</driverVersion><driverVersionComparator>EQUAL</driverVersionComparator></gfxBlacklistEntry>
   </gfxItems>
   
   <certItems>
   <certItem issuerName="MIGQMQswCQYDVQQGEwJHQjEbMBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFDT01PRE8gQ0EgTGltaXRlZDE2MDQGA1UEAxMtQ09NT0RPIFJTQSBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB">
   <serialNumber>D9UltDPl4XVfSSqQOvdiwQ==</serialNumber>
   </certItem>
   </certItems>
</blocklist>