Python Error xml.parsers.expat.ExpatError: not well-formed (invalid token): line 2, column 10 1
<p>I use python to extract Sprite from a Plist file. But i getting this error  " xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 2, column 101" and don't known how to resolve it.
Anyone can help me. Thank you so much.
This is python code :</p>

<pre><code>import os
import plistlib
from PIL import Image


class Matrix(object):
    def __init__(self, src_box, clip_box, offset):
        self.src_box = src_box
        self.clip_box = clip_box
        self.offset = offset
        self.src_size = [self.src_box[2] - self.src_box[0], self.src_box[3] - self.src_box[1]]
        self.clip_size = [self.clip_box[2] - self.clip_box[0], self.clip_box[3] - self.clip_box[1]]


class TextureUnpacker(object):
    @classmethod
    def split_with_plist(cls, plist, save=None):
        plist = os.path.abspath(plist)
        if save is None:
            save = plist + '_split'
        else:
            save = os.path.abspath(save)

        dt = plistlib.readPlist(plist)
        metadata, frames = dt['metadata'], dt['frames']
        format_version = metadata['format']
        big_img = Image.open(metadata['realTextureFileName'])
        for frame, info in frames.iteritems():
            if format_version == 2:
                info = cls.parse_as_plist_v2(info)
            elif format_version == 3:
                info = cls.parse_as_plist_v3(info)
            else:
                raise Exception('not support version' + str(format_version))
            cls.generate_little_image(big_img, info, os.path.join(save, frame))

    @classmethod
    def generate_little_image(cls, big_img, info, path):
        little_img = Image.new('RGBA', info['sz'])
        region = big_img.crop(info['box'])
        if info['rotated']:
            # region = region.rotate(90, expand=1)
            region = region.transpose(Image.ROTATE_90)
        little_img.paste(region, info['xy'])
        dir_ = os.path.dirname(path)
        if not os.path.exists(dir_):
            os.makedirs(dir_)
        little_img.save(path)

    @classmethod
    def parse_as_plist_v2(cls, info):
        """
        {
            'frame': '{{1,1},{430,635}}',
            'offset': '{2,-2}',
            'rotated': False,
            'sourceSize': '{639,639}'
        }
        """
        info['frame'] = cls.__convert_rect(info['frame'])
        info['offset'] = cls.__convert_point(info['offset'])
        info['sourceSize'] = cls.__convert_point(info['sourceSize'])

        rotated = info['rotated']
        if rotated:
            box = (info['frame'][0], info['frame'][1],
                   info['frame'][0] + info['frame'][3],
                   info['frame'][1] + info['frame'][2])
        else:
            box = (info['frame'][0], info['frame'][1],
                   info['frame'][0] + info['frame'][2],
                   info['frame'][1] + info['frame'][3])

        x = info['offset'][0] + (info['sourceSize'][0] - info['frame'][2]) / 2
        y = (info['sourceSize'][1] - info['frame'][3]) / 2 - info['offset'][1]

        return {
            'box': box,
            'rotated': rotated,
            'xy': (x, y),
            'sz': info['sourceSize']
        }

    @classmethod
    def parse_as_plist_v3(cls, info):
        """
        {
            'aliases': [],
            'spriteOffset': '{1,-1}',
            'spriteSize': '{433,637}',
            'spriteSourceSize': '{639,639}',
            'textureRect': '{{1,1},{433,637}}',
            'textureRotated': False
        }
        """
        info['spriteSize'] = cls.__convert_point(info['spriteSize'])
        info['spriteOffset'] = cls.__convert_point(info['spriteOffset'])
        info['textureRect'] = cls.__convert_rect(info['textureRect'])
        info['spriteSourceSize'] = cls.__convert_point(info['spriteSourceSize'])

        rotated = info['textureRotated']
        if rotated:
            box = (info['textureRect'][0], info['textureRect'][1],
                   info['textureRect'][0] + info['textureRect'][3],
                   info['textureRect'][1] + info['textureRect'][2])
        else:
            box = (info['textureRect'][0], info['textureRect'][1],
                   info['textureRect'][0] + info['textureRect'][2],
                   info['textureRect'][1] + info['textureRect'][3])

        x = info['spriteOffset'][0] + (info['spriteSourceSize'][0] - info['spriteSize'][0]) / 2
        y = (info['spriteSourceSize'][1] - info['spriteSize'][1]) / 2 - info['spriteOffset'][1]

        return {
            'box': box,
            'rotated': rotated,
            'xy': (x, y),
            'sz': info['spriteSourceSize']
        }

    @classmethod
    def __convert_rect(cls, rect):
        s = rect.replace('{', '')
        s = s.replace('}', '')
        x, y, w, h = s.split(',')
        return [int(x), int(y), int(w), int(h)]

    @classmethod
    def __convert_point(cls, pt):
        s = pt.replace('{', '')
        s = s.replace('}', '')
        x, y = s.split(',')
        return [int(x), int(y)]


if __name__ == '__main__':
    import sys
    TextureUnpacker.split_with_plist(sys.argv[1])
</code></pre>

<p>And this is plist file:</p>

<pre><code>&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;frames&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;Sprite_ID1212&lt;/key&gt;
            &lt;dict&gt;
                &lt;key&gt;frame&lt;/key&gt;
                &lt;string&gt;{{0, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;offset&lt;/key&gt;
                &lt;string&gt;{0, -0}&lt;/string&gt;
                &lt;key&gt;rotated&lt;/key&gt;
                &lt;string&gt;false&lt;/string&gt;
                &lt;key&gt;sourceColorRect&lt;/key&gt;
                &lt;string&gt;{{0, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;sourceSize&lt;/key&gt;
                &lt;string&gt;{640, 1156}&lt;/string&gt;
            &lt;/dict&gt;
            &lt;key&gt;Sprite_ID160&lt;/key&gt;
            &lt;dict&gt;
                &lt;key&gt;frame&lt;/key&gt;
                &lt;string&gt;{{644, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;offset&lt;/key&gt;
                &lt;string&gt;{0, -0}&lt;/string&gt;
                &lt;key&gt;rotated&lt;/key&gt;
                &lt;string&gt;false&lt;/string&gt;
                &lt;key&gt;sourceColorRect&lt;/key&gt;
                &lt;string&gt;{{0, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;sourceSize&lt;/key&gt;
                &lt;string&gt;{640, 1156}&lt;/string&gt;
            &lt;/dict&gt;
            &lt;key&gt;Sprite_ID1113&lt;/key&gt;
            &lt;dict&gt;
                &lt;key&gt;frame&lt;/key&gt;
                &lt;string&gt;{{1288, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;offset&lt;/key&gt;
                &lt;string&gt;{0, -0}&lt;/string&gt;
                &lt;key&gt;rotated&lt;/key&gt;
                &lt;string&gt;false&lt;/string&gt;
                &lt;key&gt;sourceColorRect&lt;/key&gt;
                &lt;string&gt;{{0, 0}, {640, 1156}}&lt;/string&gt;
                &lt;key&gt;sourceSize&lt;/key&gt;
                &lt;string&gt;{640, 1156}&lt;/string&gt;
            &lt;/dict&gt;
        &lt;key&gt;metadata&lt;/key&gt;
        &lt;dict&gt;
            &lt;key&gt;format&lt;/key&gt;
            &lt;string&gt;2&lt;/string&gt;
            &lt;key&gt;realTextureFileName&lt;/key&gt;
            &lt;string&gt;atlas_ID101.png&lt;/string&gt;
            &lt;key&gt;size&lt;/key&gt;
            &lt;string&gt;{2048, 2048}&lt;/string&gt;
            &lt;key&gt;smartupdate&lt;/key&gt;
            &lt;string&gt;$Potion:Smartupdate:$&lt;/string&gt;
            &lt;key&gt;textureFileName&lt;/key&gt;
            &lt;string&gt;atlas_ID101.png&lt;/string&gt;
        &lt;/dict&gt;
    &lt;/dict&gt;
&lt;/plist&gt;
</code></pre>