P
P
ppxy2014-08-31 21:02:44
Character encoding
ppxy, 2014-08-31 21:02:44

How to implement decompression of data in base64 compressed gzip from xml file. C# language?

There is an xml file from the Tile program (tile map editor) with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="5" height="5" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="blocks1" tilewidth="32" tileheight="32" spacing="2" margin="2">
  <image source="blocks1.png" width="614" height="376"/>
 </tileset>
 <layer name="Tile Layer 1" width="5" height="5">
  <data encoding="base64" compression="gzip">
   H4sIAAAAAAAAC0tmYGBIAeJUBuJAMgH12OQByaQF+GQAAAA=
  </data>
 </layer>
</map>

Need to get from element
<data encoding="base64" compression="gzip">
   H4sIAAAAAAAAC0tmYGBIAeJUBuJAMgH12OQByaQF+GQAAAA=
  </data>
list of xml elements.
Tell me where to start.
PS
Here are the settings that generate this xml code:
5262f9b19dae49c0833ba8c09949b3e6.png
Code generated without compression and without base64
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="5" height="5" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="blocks1" tilewidth="32" tileheight="32" spacing="2" margin="2">
  <image source="blocks1.png" width="614" height="376"/>
 </tileset>
 <layer name="Tile Layer 1" width="5" height="5">
  <data>
   <tile gid="99"/>
   <tile gid="100"/>
   <tile gid="101"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="99"/>
   <tile gid="100"/>
   <tile gid="101"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="0"/>
   <tile gid="99"/>
   <tile gid="100"/>
   <tile gid="101"/>
   <tile gid="0"/>
   <tile gid="0"/>
  </data>
 </layer>
</map>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soniq, 2014-08-31
@ppxy

Use System.IO.Compression.GZipStream to decompress gzip
. You can decode Base64 using System.Convert. FromBase64CharArray()
XML read as you like.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question