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.
Python mindom文档页面上有一个很好的示例,您也可以考虑使用更易于编写的JSON或将Python对象序列化为 JSON。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.