Read-XmlNode
Read-XmlNode
This command reads information from existing XML files. The dialog box specifies which information (element, attribute, content) should be read from which XML file.
To identify the part of the XML file to be processed, DSM uses specifications of the XML Path Language (XPath) 2.0. See: https://www.w3.org/TR/xpath20/
If the search finds several hits, you can use an index to determine the exact hit you are looking for.
Settings:
- Entry type
Selection of the type of the part of the XML file to be edited:
- Element - Basic structural unit of an XML file, which usually has a start and end tag.
If an element is searched for, the result variable contains the entire element with start and end tags and the complete content between these tags after the command is executed. The search for an element returns the complete element: e.g. <Object type="STRING">QueenMary</Object>. - Attribute of an element
If an attribute is searched for, the result variable contains the value of the attribute after the command is executed. The search for the attribute type in the above-mentioned example element results STRING. - Content of an element - this refers to the text content of an element between the start and end tag (without sub-elements)
If the content is searched for, the result variable contains the entire text content of the searched element between the start and end tag after the command has been executed. Subordinate elements with their associated text contents are not included. The search for the content in the above example element results in QueenMary. - XML file name
XML file to be modified. The use of variables is possible. Use the "..." button to select an existing file (on the packaging system) or enter the path manually. - XPath query
Identification of the part of the XML file to be edited using XPath syntax. With a click on the "..." button you open the XPath browser for the specified XML file, which enables a convenient selection of the searched element including its conversion into a unique XPath query. Namespaces are also taken into account. The file is only displayed if it is a "well-formed" XML file.
If the XML file in question is not available locally, select an alternative sample file that should correspond to the XML file to be edited.
The options offered in the XPath browser (index-based query, recursive search) directly influence the syntax of the XPath query and are based on the XML Path Language (XPath) 2.0 specifications. Alternatively, you can enter the XPath query manually, but in this case you must ensure that the syntax is adhered to yourself.
The XPath query allows the use of variables - Name des Attributs
Enthält den Namen des gesuchten Attributs, wenn für Typ des Eintrags der Wert "Attribut" ausgewählt wurde. Der Platzhalter * ist erlaubt. - Index
Defines which elements should be read if the query returns multiple hits in the XML file. The following elements are available for selection: - First match
- Last match
- Specific index
To do this, you must specify the position of the desired element in the hit list, e.g. 3 for the third occurrence in the XML file. - Result variable
Specifies the variable in which the result of the command is to be stored. Specify only the name of the variable, not the $ sign and curly brackets. - Counter variable
Defines the variable in which the index of the used hit should be stored. Specify only the name of the variable, not the $ sign and curly brackets. This variable can be used to determine the maximum value for a query loop. In this case you should enter the command Read-XmlNode several times in the script: first only to determine the maximum index and then in a corresponding loop to read out the individual values found. - Use 32-Bit mode on x64 computer
If the script is executed on a 64-bit operating system, the counterpart for 32-bit applications SysWOW64 can be used automatically when referring to the SYSTEM32 directory.
Example:
The example reads the version of the App Deployment Toolkit from the XML file AppDeployToolkitConfig.xml and saves the result in the variable _ADTVersion:
Corresponds to DSM eScript command:
- ReadXML
See also: