I have a following short example:
set XML {<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='query.xsl'?>
<objList label="Key Result" numPages="1" page="1" pageSize="1000"
total="84" type="KeyResult" version="1.5.1">
<query>1;Project;\[name=='/Data/Project1'\].sdmObjects:Variant\[
phase.name=='Early'\].models:inputFile\[simulationDef.scenario.label=='SimulationSet1'\].results.keyResults\[
type.name=='PPTDocument'\]</query>
<view>
<field label="inputFile" list="false" name="inputFile" type="DbObject"/>
<field label="Files" list="false" name="files" type="Document"/>
</view>
<obj oid="lCcAAAAByA2xNM:TXFMiw" type="PPTDocument">
<attr name="inputFile" oid="AAAABwnTnv8:B1M">Dataset_v019_GFZ</attr>
<attr name="files">
<file
name="Report_Dataset_v018d_GFZ_vs_Dataset_v019_GFZ.pptx"
role="role_1" size="26035115"/>
</attr>
</obj>
<obj oid="ey8AAAAB6xzKp8:TXFMiw" type="PPTDocument">
<attr name="inputFile" oid="AAAAB6F0PcM:B1M">Dataset_F20EG040</attr>
<attr name="files">
<file
name="Report_Dataset_F20EG039_vs_Dataset_F20EG040.pptx"
role="role_1" size="34545819"/>
</attr>
</obj>
</objList>
}
set doc [dom parse $XML]
set root [$doc documentElement]
# Since there are more than one order nodes a Tcl list will be returned from the selectNodes method.
set nodeList [$root selectNodes /objList/obj]
# Parse node1 from the returned list.
set item [lindex $nodeList 0]
puts [$item asText]
set oid [lindex [$item selectNodes {@oid}] 0 1]
set deckName [[$item selectNodes {attr[@name='inputFile']}] asText]
set fileName [$item selectNodes ".attributes/files"]
set file [$fileName nodeValue]
puts "$oid $deckName $file"
I would like get both oid(s) for PPTDocument and inputFile which I think I can manage. I have, however, huge problems navigating down and getting the file name of the powerpoint. I was able to get there directly by
starting with [$doc selectNodes {/objList/obj/attr/file}]
set name [lindex [$node selectNodes {@name}] 0 1]
set role [lindex [$node selectNodes {@role}] 0 1]
but starting earlier own I do not know how to get down a branch - I really suck in this XML stuff