M
manu
Hi,
I need to parse xml files for the Blender Game Engine. ATM I am trying
to get this script running in the BGE. This is my first script and I
dont have much experience programming...
import xml.sax
class PnmlHandler(xml.sax.ContentHandler):
def __init__(self):
self.inPlace=0
def startElement(self, name, attrs):
if name != "place": return
if attrs.getLength()==0: return
print 'Starting element:', name
print "attrs:", attrs.keys()
id = attrs.get("id", None)
print "id:", id
if name == "place":
self.inPlace=1
def endElement(self, name):
if name == "place":
self.inPlace=0
parser = xml.sax.make_parser()
parser.setContentHandler(PnmlHandler())
parser.parse(open("bpm.pnml","r"))
this works in the IDLE ide. Output:
Starting element: place
attrs: [u'id']
id: p9723441
Starting element: place
attrs: [u'id']
id: p26811937
Starting element: place
attrs: [u'id']
id: p24278422[/code]
but when I copy the script into blender and run it I get:
Its probably a stupid question but thanks anyway!
I need to parse xml files for the Blender Game Engine. ATM I am trying
to get this script running in the BGE. This is my first script and I
dont have much experience programming...
import xml.sax
class PnmlHandler(xml.sax.ContentHandler):
def __init__(self):
self.inPlace=0
def startElement(self, name, attrs):
if name != "place": return
if attrs.getLength()==0: return
print 'Starting element:', name
print "attrs:", attrs.keys()
id = attrs.get("id", None)
print "id:", id
if name == "place":
self.inPlace=1
def endElement(self, name):
if name == "place":
self.inPlace=0
parser = xml.sax.make_parser()
parser.setContentHandler(PnmlHandler())
parser.parse(open("bpm.pnml","r"))
this works in the IDLE ide. Output:
Starting element: place
attrs: [u'id']
id: p9723441
Starting element: place
attrs: [u'id']
id: p26811937
Starting element: place
attrs: [u'id']
id: p24278422[/code]
but when I copy the script into blender and run it I get:
Code:
Compiled with Python version 2.5.
Checking for installed Python... got it!
Traceback (most recent call last):
File "Text", line 27, in <module>
File "H:\Python25\lib\xml\sax\__init__.py", line 93, in make_parser
raise SAXReaderNotAvailable("No parsers found", None)
xml.sax._exceptions.SAXReaderNotAvailable: No parsers found
Its probably a stupid question but thanks anyway!