ModifyXML

Modify XML file

Related Topics Link IconRelated Topics

Definition

Use this command to add new entries to an XML file or to change or delete existing entries. The changed file is only stored if the XML file is well-formed, the schema is not validated, however.
In the dialog box you can specify which of the information can be edited in the XML file (Element, Attribute, Contents). Elements can only be added or deleted, attributes and contents can also be changed.

To identify the editable part of the XML file, DSM uses the specifications of the XML Path Language (XPath) 2.0.
See also: https://www.w3.org/TR/xpath20/

If there are several matches for the part of the XML file you want to edit, you can use an index to specify the match exactly.

Settings

Input

  • Entry type
    Select the type of the part of the XML file you want to edit:
    • Element - Basic structural unit of an XML file that usually has a tag at the beginning and the end.
      If you want to delete an element, the element that is identified in the XPath query is deleted with all subelements and contents. If you want to add a new element, the contents of the field Entry value is added to the specified element of the XML file.
      If you have not specified an XML query, the contents of the field Entry value is used to replace the complete contents of the XML file. This is how you can create a new XML file.
    • Attribute of an element
      If you want to delete an attribute, the attribute is deleted completely from the element identified in the XPath query .
      If you want to add or change an attribute, the attribute is added to the identified element. The command automatically detects whether the attribute already exists and acts accordingly.
    • Contents of an element - This refers to the text content of an element between the start and end tag (without subelements)
      If you want to delete the contents of an element, the contents are deleted completely from the element identified in the XPath query.
      If you want to add or change the contents of an element, the contents are added to the identified element or they replace the existing contents.
      Subelements are not treated as contents and therefore they are ignored.
  • Action
    The following actions are available:
    • Add
    • Change
      This action does not apply to the type Element.
      If attributes or contents need to be changed but are not available, they are added automatically.
    • Delete
  • XML file name
    Path and name of the XML file you want to edit. If not specified, the extension .XML is used automatically.
  • XPath query
    Used to identify the editable part of the XML file with the help of the XPath syntax.
    Click ... to open the XPath browser for the specified XML file; this browser helps you select the element and converts it to a unique XPath query. Namespaces are also considered. The file is only displayed if the XML file is well-formed.
    In case the respective XML file is not available locally, select an alternative sample file that matches the XML file you want to edit.
    The available options in the XPath  Browser (index-based queries, recursive search) have a direct impact on the XPath query syntax and are based on the specifications of the XML Path Language (XPath) 2.0. Alternatively, you can enter the XPath query manually; in this case, make sure to keep the correct syntax.
    You can use eScript variables with XPath queries.

    XPath query example:
    //Sample/node1/node2/Object[@type="STRING"]
    In this example, the system queries the Object element in Sample/node1/node2 to which the type="STRING" applies.
    In most cases, the system finds several elements that match the query; therefore, specify an Index in addition.
    Find more examples in ModifyXML - Example

  • Index
    The index determines which element is to be edited if the query finds several matches in the XML file.
    The following options are available:
    • All (default)
    • First match
    • Last match
    • Specific index
      Specify the location of the specific element on the match list, for example 3 for the third incidence in the XML file. If necessary, use the ReadXML command to define the respective index value.
  • Attribute name
    This entry provides the name of the queried attribute if you select Entry type = Attribute. You are allowed to use the * wild card.
  • Entry value
    Specifies the XML contents (for the actions Add and Change) that will be replaced and/or added to the XML file.
    Click ... to open an editor where you can enter complex or multiple lined contents.
    You can use variables.

Options

Disable file direction on x64 computers
For reasons of compatibilty, Ivanti DSM maps file and registry access to the default storage location for 32 bit applications (provided that the storage location differs from that of 64-bit applications). File access: whenever a 32-bit application attempts to access %windir%\System32, the access is redirected to %windir%\SysWOW64. Registry commands: when accessing HKEY_LOCAL_MACHINE\SOFTWARE the calls are redirected to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node. The x64-switch stops this redirection of file and registry accesses when running the script command on a x64 computer; the eScript command runs on the specified path. CallScript command: the script runs in a 64-bit process.