[ERLEDIGT] Probleme beim Auslesen einer XML-File

JMS
Beiträge: 94
Registriert: 22 Nov 2010, 12:05

[ERLEDIGT] Probleme beim Auslesen einer XML-File

Beitragvon JMS » 19 Dez 2018, 13:04

Hallo zusammen,

vielleicht sehe ich vor lauter Bäumen den Wald nicht mehr, aber ich hänge gerade fest und komme nicht weiter... vielleicht kann mir jemand 'nen Tipp geben:

Ich habe ein Paket gebaut, dass auf Client-Systemen "Dell Command | Update" als CLI ausführt. Das commandline-Tool spuckt nach dem Lauf eine XML aus, die ich nun einlesen will.

Das von dcu_cli.exe generierte XML sieht wie folgt aus (wird ins Log angehängt, daher hier Uhrzeit & Paketname entfernt)

Code: Alles auswählen

(747)Start including tail of LogFile "C:\tmp\SPMS_k000000-st-sto-dell_commandupdate_v2_2.4.1_run_20181219-1212.xml with encoding: utf8"
(748)################################################################
(749)==>: <?xml version="1.0"?>
(750)==>: <updates xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1.2" schemaVersion="1.2">
(751)==>:   <update>
(752)==>:     <release>341WV</release>
(753)==>:     <name>Intel Rapid Storage Technology Driver and Management Console</name>
(754)==>:     <version>A00 (13.0.0.1098)</version>
(755)==>:     <date>April 10, 2014</date>
(756)==>:     <urgency>Recommended</urgency>
(757)==>:     <type>Driver</type>
(758)==>:     <category>Serial ATA</category>
(759)==>:     <file>downloads.dell.com/FOLDER02125048M/1/Serial-ATA_Driver_341WV_WN_13.0.0.1098_A00.EXE</file>
(760)==>:     <bytes>19097608</bytes>
(761)==>:   </update>
(762)==>:   <update>
(763)==>:     <release>JRHH9</release>
(764)==>:     <name>Intel HD, HD 4000 Graphics Driver</name>
(765)==>:     <version>A02 (10.18.10.4276)</version>
(766)==>:     <date>March 17, 2016</date>
(767)==>:     <urgency>Recommended</urgency>
(768)==>:     <type>Driver</type>
(769)==>:     <category>Video Drivers</category>
(770)==>:     <file>downloads.dell.com/FOLDER03615133M/1/Video_Driver_JRHH9_WN32_10.18.10.4276_A02.EXE</file>
(771)==>:     <bytes>80933240</bytes>
(772)==>:   </update>
(773)==>:   <update>
(774)==>:     <release>KFR45</release>
(775)==>:     <name>Intel(R) Management Engine Components Installer Driver,11.0.0.1153</name>
(776)==>:     <version>A00 (11.0.0.1146)</version>
(777)==>:     <date>June 30, 2015</date>
(778)==>:     <urgency>Recommended</urgency>
(779)==>:     <type>Driver</type>
(780)==>:     <category>Chipset Driver</category>
(781)==>:     <file>downloads.dell.com/FOLDER03137147M/1/Chipset_Driver_KFR45_WN32_11.0.0.1153_A00.EXE</file>
(782)==>:     <bytes>109468224</bytes>
(783)==>:   </update>
(784)==>: </updates>
(785)################################################################
(786)End including LogFile "C:\tmp\SPMS_k000000-st-sto-dell_commandupdate_v2_2.4.1_run_20181219-1212.xml"


Gemäß Kapitel "12.6. XML-Datei einlesen mit dem opsi-winst" bin ich wie folgt vorgegangen:
Ich befülle eine Stinglist über Sektion "XMLPatch_findUpdates"...

Code: Alles auswählen

set $list$ = getReturnListFromSection ('XMLPatch_findUpdates '+$LogFileRunFile$)

... wobei die Sektion wir folgt aussieht:

Code: Alles auswählen

[XMLPatch_findUpdates]
openNodeSet
        ; Knoten „updates“ ist der documentroot
        documentroot
        all_childelements_with:
          elementname:"update"
        all_childelements_with:
          elementname:"file"
end
return elements


Zurück bekomme bekomme ich dann nur das hier zurück: :(

Code: Alles auswählen

(787)     [9]      Parsingprogress: r: DefStringList $list$ exp:
(788)     [9]      Parsingprogress: r: $list$ exp: DefStringList
(790)     [7]      (created string list $list$)
(791)     [9]      Parsingprogress: r: DefVar $line$ exp:
(792)     [9]      Parsingprogress: r: $line$ exp: DefVar
(793)     [9]      Parsingprogress: r: set $list$ = getReturnListFromSection ('XMLPatch_findUpdates '+$LogFileRunFile$) exp:
(794)     [9]      Parsingprogress: r: $list$ = getReturnListFromSection ('XMLPatch_findUpdates '+$LogFileRunFile$) exp: set
(795)     [6]      Set  $list$ = getReturnListFromSection ('XMLPatch_findUpdates '+$LogFileRunFile$)
(796)     [9]      Looking for section: XMLPatch_findUpdates in standard section.
(797)     [9]      Looking for section: XMLPatch_findUpdates in global section.
(798)     [5]
(799)     [5] Execution of XMLPatch_findUpdates "C:\Program Files\opsi.org\opsi-client-agent\opsi-winst\opsiwinstxmlplugin.exe" --xmlfile="C:\tmp\SPMS_k000000-st-sto-dell_commandupdate_v2_2.4.1_run_20181219-1212.xml" --scriptfile=
(800)     [7]   Save to file with encoding: system
(801)     [8]   Will save (system) to file: c:\opsi.org\tmp\_opsiscript_Ob88Mv37.cmd :
(802)     [9]   -----------------
(803)     [9]   openNodeSet
(804)     [9]   documentroot
(805)     [9]   all_childelements_with:
(806)     [9]   elementname:"update"
(807)     [9]   all_childelements_with:
(808)     [9]   elementname:"file"
(809)     [9]   end
(810)     [9]   return elements
(811)     [9]   -----------------
(812)     [8]   Content of saved file: c:\opsi.org\tmp\_opsiscript_Ob88Mv37.cmd
(813)     [8]   -----------------------
(814)     [7]   openNodeSet
(815)     [7]   documentroot
(816)     [7]   all_childelements_with:
(817)     [7]   elementname:"update"
(818)     [7]   all_childelements_with:
(819)     [7]   elementname:"file"
(820)     [7]   end
(821)     [7]   return elements
(822)     [8]   -----------------------
(823)     [6]   ExitCode 0
(824)     [7]           
(825)     [7]           output:
(826)     [7]           --------------
(827)     [7]           file
(828)     [7]           file
(829)     [7]           file
(830)     [7]   
(831)     [7] Start including tail of LogFile "c:\opsi.org\log\opsiwinstxmlplugin.log with encoding: utf8"
(832)     [7] ################################################################
(833)     [7] ==>: [5] --
(834)     [7] ==>: [5] --
(835)     [7] ==>: EInOutError:E/A-Fehler 103
(836)     [7] ==>: [5]
(837)     [7] ==>: [5] Execution of
(838)     [7] ==>: [5]         FILE C:\tmp\SPMS_k000000-st-sto-dell_commandupdate_v2_2.4.1_run_20181219-1212.xml
(839)     [7] ==>: [6]     DOM Vendor Open XML
(840)     [7] ==>: [6]     XML Options [doNodeAutoIndent, doAutoPrefix, doNamespaceDecl]
(841)     [7] ==>: [6]     Activated XMLDocument from file  C:\tmp\SPMS_k000000-st-sto-dell_commandupdate_v2_2.4.1_run_20181219-1212.xml
(842)     [7] ==>: [6]
(843)     [7] ==>: [6]
(844)     [7] ==>: [6]   Open node set
(845)     [7] ==>: [6]
(846)     [7] ==>: [6]     retaining child elements with name = "update"
(847)     [7] ==>: [6]     no filtering by textvalue requested
(848)     [7] ==>: [6]     no filtering by attributes requested
(849)     [7] ==>: [6]
(850)     [7] ==>: [6]     actNodeSet:
(851)     [7] ==>: [6]        node 0 elementname: "updates"
(852)     [7] ==>: [0]     Non-null element(s) in act node set: 1
(853)     [7] ==>: [6]     derivedNodeSet:
(854)     [7] ==>: [6]        node 0 elementname: "update"
(855)     [7] ==>: [6]        node 1 elementname: "update"
(856)     [7] ==>: [6]        node 2 elementname: "update"
(857)     [7] ==>: [6]     Non-null element(s) remaining in children node set: 3
(858)     [7] ==>: [6]
(859)     [7] ==>: [6]         -------
(860)     [7] ==>: [6]     Going to the next level ...
(861)     [7] ==>: [6]
(862)     [7] ==>: [6]     actNodeSet:
(863)     [7] ==>: [6]        node 0 elementname: "update"
(864)     [7] ==>: [6]        node 1 elementname: "update"
(865)     [7] ==>: [6]        node 2 elementname: "update"
(866)     [7] ==>: [0]     Non-null element(s) in act node set: 3
(867)     [7] ==>: [6]     derivedNodeSet:
(868)     [7] ==>: [6]        node 0 elementname: "release"
(869)     [7] ==>: [6]        node 1 elementname: "name"
(870)     [7] ==>: [6]        node 2 elementname: "version"
(871)     [7] ==>: [6]        node 3 elementname: "date"
(872)     [7] ==>: [6]        node 4 elementname: "urgency"
(873)     [7] ==>: [6]        node 5 elementname: "type"
(874)     [7] ==>: [6]        node 6 elementname: "category"
(875)     [7] ==>: [6]        node 7 elementname: "file"
(876)     [7] ==>: [6]        node 8 elementname: "bytes"
(877)     [7] ==>: [6]        node 9 elementname: "release"
(878)     [7] ==>: [6]        node 10 elementname: "name"
(879)     [7] ==>: [6]        node 11 elementname: "version"
(880)     [7] ==>: [6]        node 12 elementname: "date"
(881)     [7] ==>: [6]        node 13 elementname: "urgency"
(882)     [7] ==>: [6]        node 14 elementname: "type"
(883)     [7] ==>: [6]        node 15 elementname: "category"
(884)     [7] ==>: [6]        node 16 elementname: "file"
(885)     [7] ==>: [6]        node 17 elementname: "bytes"
(886)     [7] ==>: [6]        node 18 elementname: "release"
(887)     [7] ==>: [6]        node 19 elementname: "name"
(888)     [7] ==>: [6]        node 20 elementname: "version"
(889)     [7] ==>: [6]        node 21 elementname: "date"
(890)     [7] ==>: [6]        node 22 elementname: "urgency"
(891)     [7] ==>: [6]        node 23 elementname: "type"
(892)     [7] ==>: [6]        node 24 elementname: "category"
(893)     [7] ==>: [6]        node 25 elementname: "file"
(894)     [7] ==>: [6]        node 26 elementname: "bytes"
(895)     [7] ==>: [6]     Non-null element(s) remaining in children node set: 27
(896)     [7] ==>: [6]
(897)     [7] ==>: [6]         -------
(898)     [7] ==>: [6]
(899)     [7] ==>: [6]     retaining child elements with name = "file"
(900)     [7] ==>: [6]     no filtering by textvalue requested
(901)     [7] ==>: [6]     no filtering by attributes requested
(902)     [7] ==>: [6]
(903)     [7] ==>: [6]     actNodeSet:
(904)     [7] ==>: [6]        node 0 elementname: "update"
(905)     [7] ==>: [6]        node 1 elementname: "update"
(906)     [7] ==>: [6]        node 2 elementname: "update"
(907)     [7] ==>: [0]     Non-null element(s) in act node set: 3
(908)     [7] ==>: [6]     derivedNodeSet:
(909)     [7] ==>: [6]        node 0 null
(910)     [7] ==>: [6]        node 1 null
(911)     [7] ==>: [6]        node 2 null
(912)     [7] ==>: [6]        node 3 null
(913)     [7] ==>: [6]        node 4 null
(914)     [7] ==>: [6]        node 5 null
(915)     [7] ==>: [6]        node 6 null
(916)     [7] ==>: [6]        node 7 elementname: "file"
(917)     [7] ==>: [6]        node 8 null
(918)     [7] ==>: [6]        node 9 null
(919)     [7] ==>: [6]        node 10 null
(920)     [7] ==>: [6]        node 11 null
(921)     [7] ==>: [6]        node 12 null
(922)     [7] ==>: [6]        node 13 null
(923)     [7] ==>: [6]        node 14 null
(924)     [7] ==>: [6]        node 15 null
(925)     [7] ==>: [6]        node 16 elementname: "file"
(926)     [7] ==>: [6]        node 17 null
(927)     [7] ==>: [6]        node 18 null
(928)     [7] ==>: [6]        node 19 null
(929)     [7] ==>: [6]        node 20 null
(930)     [7] ==>: [6]        node 21 null
(931)     [7] ==>: [6]        node 22 null
(932)     [7] ==>: [6]        node 23 null
(933)     [7] ==>: [6]        node 24 null
(934)     [7] ==>: [6]        node 25 elementname: "file"
(935)     [7] ==>: [6]        node 26 null
(936)     [7] ==>: [6]     Non-null element(s) remaining in children node set: 3
(937)     [7] ==>: [6]
(938)     [7] ==>: [6]         -------
(939)     [7] ==>: [6]     Going to the next level ...
(940)     [7] ==>: [6]
(941)     [7] ==>: [6]     actNodeSet:
(942)     [7] ==>: [6]        node 0 elementname: "file"
(943)     [7] ==>: [6]        node 1 elementname: "file"
(944)     [7] ==>: [6]        node 2 elementname: "file"
(945)     [7] ==>: [0]     Non-null element(s) in act node set: 3
(946)     [7] ==>: [6]     derivedNodeSet:
(947)     [7] ==>: [6]        node 0 elementname: "#text"
(948)     [7] ==>: [6]        node 1 elementname: "#text"
(949)     [7] ==>: [6]        node 2 elementname: "#text"
(950)     [7] ==>: [6]     Non-null element(s) remaining in children node set: 3
(951)     [7] ==>: [6]
(952)     [7] ==>: [6]         -------
(953)     [7] ==>: [6]     returning all selected elements
(954)     [7] ################################################################
(955)     [7] End including LogFile "c:\opsi.org\log\opsiwinstxmlplugin.log"
(956)     [8]   retrieving strings from getReturnListFromSection
(957)     [8]       (string   0)file
(958)     [8]       (string   1)file
(959)     [8]       (string   2)file
(960)     [8]       
(961)     [7] The value of the variable "$list$" is now:
(962)     [7] (string   0)file
(963)     [7] (string   1)file
(964)     [7] (string   2)file



Kurzum: Das XML wird eingelesen, die richtige Anzahl Updates (aus <files></files>) wird erkannt, nur eben nicht das, was zwischenden den Notationen <files></files> steht.

Das hier will ich eigentlich haben (ohne Notationen):
<file>downloads.dell.com/FOLDER02125048M/1/Serial-ATA_Driver_341WV_WN_13.0.0.1098_A00.EXE</file>
<file>downloads.dell.com/FOLDER03615133M/1/Video_Driver_JRHH9_WN32_10.18.10.4276_A02.EXE</file>
<file>downloads.dell.com/FOLDER03137147M/1/Chipset_Driver_KFR45_WN32_11.0.0.1153_A00.EXE</file>



Hat jemand eine Idee, was ich falsch machen?


Viele Grüße

JMS
Zuletzt geändert von JMS am 19 Dez 2018, 13:15, insgesamt 1-mal geändert.

JMS
Beiträge: 94
Registriert: 22 Nov 2010, 12:05

Re: Probleme beim Auslesen einer XML-File

Beitragvon JMS » 19 Dez 2018, 13:15

Uuaaargh.... Hirn einschalten!!

Die Sektion muss wie folgt aussehen

Code: Alles auswählen

[XMLPatch_findUpdates]
openNodeSet
        ; Knoten „updates“ ist der documentroot
        documentroot
        all_childelements_with:
          elementname:"update"
        all_childelements_with:
          elementname:"file"
end
return text



Das hier ist der Knackpunkt:
Statt "return elements" "return text"... dann klappts auch ;-)

Viele Grüße

JMS