XML get Values of all nodes with a specific name below root

Hi, i need to get Values out of an XML. The xml is too big for trying so i made an small XML.
I use the bakery package.
I try to get the value of “from”, “heading” and “body”. I tryed a lot of different xpath, but it didn’t work.
Is there a better way to get to my goal? Any help would be good.


note.xml

here is my dynamo workflow:

here is a example how it can be done…but i don’t get so far and i don’t think it is the best way to do it.

Have you tried the XML-nodes from the Lunchbox package?

Hi Hannes

If this is a clash results XML file from Navisworks- I struggled with using Dynamo to do this (although it is probably possible)
The Dynaworks package is also an option

I ended up using a (free) tool called Pentaho Data Integration which transforms the XML into a nice, tidy database
I then used Dynamo to create sphere markers for each clash in Revit, with properties from the XML as parameters for each clash sphere. Although it take several steps, it is fast & reliable.

hope this helps

Andrew

Yes i tried the Lunchbox package. It worked fine for one node. But i need to get all nodes from the same typ in one specific node and that is in my opinion not possible with Lunchbox nodes. Or is this possible?!:wink:

He thx, Andrew, i give Dynaworks a chance!

Heho, i solved my problem.
I made a python script. But the bakery package worked as well!
My main mistake was a false xpath!..so hear is my solution.


here is my python code(all in one)

import clr
import sys
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
sys.path.append(“C:\Program Files (x86)\IronPython 2.7\Lib”)
import xml.etree.ElementTree as ET

path = IN[0]
xpathstr = IN[1]

uniStr = unicode(open(path, ‘r’).read())
fixed = uniStr.encode(‘ascii’, ‘replace’)
fixed.decode(‘utf-8’, ‘replace’)
tree = ET.ElementTree(ET.fromstring(fixed))
list=

root = tree.getroot()
specific = root.findall(xpathstr)
for elem in specific:
list.extend(elem.itertext())

OUT = tree, root, specific,list

So if u want a specifc note below a specific note you can use this xpath

.//note1//note2

and don’t forget the namespaces, if your xml had some;)

Doesnt work for me:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 14, in
File “C:\Program Files (x86)\IronPython 2.7\Lib\xml\etree\ElementTree.py”, line 1285, in XML
File “C:\Program Files (x86)\IronPython 2.7\Lib\xml\etree\SimpleXMLTreeBuilder.py”, line 84, in feed
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 167, in feed
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 283, in goahead
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 693, in parse_endtag
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 722, in finish_endtag
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 790, in syntax_error
xmllib.Error: Syntax error at line 156: missing close tag for meta

Hi @Nikolay_Gerasimov1, i am having a similar error to what you have. did you solve it?

"
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “C:\Program Files (x86)\IronPython 2.7\Lib\xml\etree\SimpleXMLTreeBuilder.py”, line 84, in feed
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 167, in feed
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 258, in goahead
File “”, line 24, in
File “C:\Program Files (x86)\IronPython 2.7\Lib\xml\etree\ElementTree.py”, line 1177, in parse
File “C:\Program Files (x86)\IronPython 2.7\Lib\xml\etree\ElementTree.py”, line 653, in parse
File “C:\Program Files (x86)\IronPython 2.7\Lib\xmllib.py”, line 790, in syntax_error
xmllib.Error: Syntax error at line 1: illegal data at start of file
"