It looks like you're new here. If you want to get involved, click one of these buttons!
I want to read an XML file and convert it to a dict.
The first method works fine in OSX / Linux, but in Windows we are missing a module...
https://stackoverflow.com/questions/2148119/how-to-convert-an-xml-string-to-a-dictionary-in-python
So I tried with Qt. The following doesn't work, and I don't know why.
filepath = "klayout_Layers_EBeam.lyp"
# file=open(filepath,'r')
# a=file.read()
# file.close()
qfile = QFile(filepath)
source=QXmlInputSource(qfile)
handler=QXmlContentHandler()
error_handler = QXmlErrorHandler()
# source.data = a
# reader = QXmlReader() # error: Abstract method called...
reader = QXmlSimpleReader()
reader.setContentHandler(handler)
reader.setErrorHandler(error_handler)
reader.parse(source)
# Error: Ambiguous overload variants - multiple method declarations match arguments in QXmlSimpleReader.parse
thank you
Lukas
Comments
Hi Lukas,
thanks for reporting this issue. There are actually too many overloads of "parse" - I'll remove one (https://github.com/klayoutmatthias/klayout/issues/62)
Best regards,
Matthias
Hi Lukas,
I have fixed the issue, but I'm afraid it won't be of much help. The simple XML parser API is deployed by implementing a couple of interfaces. That's kind of tedious in Python.
An easier solution is to use the DOM API. Here is an example how to do basic reading of a .lyp file using the QDom... classes:
Best regards,
Matthias