Reputation: 810
I am working with MODO python scripts. I imported the MODO setting data into .cfg file with the XML format .
My .cfg file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<camera>
<Position>
<X>
2.0
</X>
<Y>
0.75
</Y>
<Z>
4.0
</Z>
</Position>
"
"
so on......
Now,i wanted to export this file into my MODO application.So,i need to parse this .cfg file (xml format).
I tried this:
#python
import lx
import xml.dom.minidom
from xml.dom.minidom import Node
dom1 = xml.dom.minidom.parse("c:\myfile.cfg")
When i try to run this script in my MODO application,it gives me following error:
Line 26 is dom1 = xml.dom.minidom.parse("c:\myfile.cfg")
How do i parse my .cfg file with xml format using minidom object in python ??? Thanx in advance.
Upvotes: 0
Views: 304
Reputation: 3075
There's a pretty good example on Python mindom documentation page you can also consider using JSON which is easier to write, or serialise Python objects to JSON.
Upvotes: 1