#! /usr/bin/env python2
# vim: set fenc=utf8 ts=4 sw=4 et :
import sys
import json
import xml.sax

class PdmlHandler( xml.sax.ContentHandler ):
    def __init__(self):
        self.CurrentData = ""
        self.type = ""
        self.format = ""
        self.year = ""
        self.rating = ""
        self.stars = ""
        self.description = ""

    def boolify(self, s):
        if s == 'True':
            return True
        if s == 'False':
            return False
        raise ValueError("Not a bool")

    # Try to convert variables into datatypes
    def autoconvert(self, s):
        for fn in (self.boolify, int, float):
            try:
                return fn(s)
            except ValueError:
                pass
        return s

    # Call when an element starts
    def startElement(self, tag, attributes):
        self.CurrentData = tag
        if tag == "packet":
            pkt.clear()
        else:
            if attributes.has_key("name"):
                name = attributes.getValue("name")
            if attributes.has_key("show"):
                pkt[name] = self.autoconvert(attributes.getValue("show"))
            if attributes.has_key("showname"):
                pkt['{}.show'.format(name)] = attributes.getValue("showname")

    # Call when an elements ends
    def endElement(self, tag):
        if tag == "packet":
            json.dump(pkt,sys.stdout)
            sys.stdout.write("\n")
            sys.stdout.flush()

    # Call when a character is read
    def characters(self, content):
        pass

if ( __name__ == "__main__"):
    #pkt dictionary 
    pkt = {}   
    # create an XMLReader
    parser = xml.sax.make_parser()
    # turn off namepsaces
    parser.setFeature(xml.sax.handler.feature_namespaces, 0)
    # override the default ContextHandler
    Handler = PdmlHandler()
    parser.setContentHandler( Handler )
    parser.parse(sys.stdin)

@@ -164,188 +164,8 @@
 lf):
-%0A        self.CurrentData = %22%22%0A        self.type = %22%22%0A        self.format = %22%22%0A        self.year = %22%22%0A        self.rating = %22%22%0A        self.stars = %22%22%0A        self.description = %22%22
 %0A%0A  
@@ -647,39 +647,8 @@
 s):%0A
-        self.CurrentData = tag%0A
     

Remove unnecessary code