2

I am writing code to parse XML (actually, KML) files and load them to a database. I would like to run the code under either Python or IronPython.

Unfortunately, I find that xml.dom.minidom will not load under IronPython because it has a dependency on expat.py, which is not implemented on IronPython. I also tried using try / except blocks to get an XML document object from either platform. Although I can obtain a document gracefully running under either platform the internal implementations of the documents are too different to write code that runs under either platform.

Is there an XML parsing strategy that is compatible across Python and IronPython?

1 Answer 1

2

According to this webpage, you may be able to get xml.dom.minidom running (if the only missing part is expat.py):

"Download FePy's pyexpat.py, copy it to IronPython's Lib/xml/parsers subdirectory, and rename it to expat.py."

Related: http://ironpython.codeplex.com/workitem/20023

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! One step missing on that web page — you must also copy (from the standard Python library) xml.dom.expatbuilder.py. With those two changes made, my code runs on both platforms!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.