Note that there are some explanatory texts on larger screens.

plurals
  1. POIronPython XML-Reader in .Net 2.0
    primarykey
    data
    text
    <p>I created a XML-Reader that creates a pretty stupid formated List, the script thats goint to use it needs it this way though.</p> <pre><code>import xml.etree.ElementTree as ET PATH_IN = "&lt;Path&gt;\sweep.xml" tree = ET.parse(PATH_IN) root = tree.getroot() Input = [] for project in root: for design in project: list_lvl2 = [] list_lvl2.append(project.get('name')) list_lvl2.append(design.get('name')) list_lvl2.append('') list_lvl3 = [] for param in design: list_lvl4 = [] list_lvl4.append(param.get('name')) list_lvl5 = [] for steps in param: list_lvl5.append(steps.text) list_lvl4.append(list_lvl5) list_lvl4.append(param.get('unit')) list_lvl3.append(list_lvl4) list_lvl2.append(list_lvl3) Input.append(list_lvl2) </code></pre> <p>Problem is I have to execute it in the Scripting Interface of a Program which uses IronPython 2.6.10920.0 on .NET 2.0.50727.5466. And it throws following error:</p> <pre><code>*Global - Messages [error] ImportException: No module named expat; use SimpleXMLTreeBuilder instead In file "&lt;Path&gt;/sweep.py", line 36 ---- While executing script: &lt;Path&gt;/sweep.py [error] Error executing script in &lt;Path&gt;\sweep.py: [error] ImportException: No module named expat; use SimpleXMLTreeBuilder instead In file "&lt;Path&gt;/sweep.py", line 36 ---- While executing script: &lt;Path&gt;/sweep.py [error] Error executing script in &lt;Path&gt;\sweep.py: </code></pre> <p>What I don't understand is that this script which uses the same module works fine:</p> <pre><code>import xml.etree.ElementTree as ET path = "&lt;Path&gt;\projects.xml" root = ET.Element('xml') projects = oDesktop.GetProjectList() for i in projects: project = ET.SubElement(root,'project') project.set('name', i) designs = oDesktop.SetActiveProject(i).GetTopDesignList() for u in designs: design = ET.SubElement(project,'design') design.set('name', u) vars = oDesktop.SetActiveProject(i).GetDesign(u).GetVariables() for z in vars: param = ET.SubElement(design,'param') param.set('name', z) value = ET.SubElement(param,'value') value.text = oDesktop.SetActiveProject(i).GetDesign(u).GetVariableValue(z) f = open(path, "w") tree = ET.ElementTree(root) tree.write(f) f.close() </code></pre> <p>oDesktop and such are just programspecific functions that fetch data. I really don't understand why the first script won't work, I'm guessing because of NET 2.0.</p> <p>UPDATE: After looking up what expat is, I'm even more confused since I never use it anywhere and all elementtree functions I use should be supported whith this version of Iron Python. Still it gives me the expat error on this line <code>tree = ET.parse(PATH_IN)</code></p> <p>UPDATE: I tried using <code>from elementtree import SimpleXMLTreeBuilder as ET</code> which resulted in:</p> <pre><code>*Global - Messages [error] ImportException: No module named elementtree In file "&lt;Path&gt;/sweep.py", line 3 ---- While executing script: &lt;Path&gt;/sweep.py [error] Error executing script in &lt;Path&gt;\sweep.py: </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload