Unsupported content

 

This version of the product is no longer supported. However, the documentation is available for your convenience. You will not be able to leave comments.

xpath.openDocument

xpath.openDocument(string)

Returns the DOM object resulting from parsing the XML string.The DOM object returned is suitable for passing to xpath.evaluate.

Parsing the XML once is considerably more efficient if you wish to call xpath.evaluate on the same XML.

You should use .xpath.closeDocument once xpath evaluation is complete or the parsed DOM will be held in memory for some time.

For example, the sample code for opening, reading, and closing a file for the AirWatch.MobileDeviceManagement pattern module is:

if process.cmd matches regex '^\w:' then

      // *filepath_info_start
      // filepath_windows := "<process.cmd>.config"
      // reason := "To get database details"
      // when := "Only if trigger process has fully qualified path"
      // *filepath_info_end
      config_file := discovery.fileGet(host, '%process.cmd%.config');
      if config_file and config_file.content then
          config_file_content_xpath := xpath.openDocument(config_file.content);
          db_name_list := xpath.evaluate(config_file_content_xpath, raw '/configuration/dataConfiguration/@defaultDatabase');
          if db_name_list then
              db_name := db_name_list[0];
              db_connection_list := xpath.evaluate(config_file_content_xpath, '/configuration/connectionStrings/add[@name="%db_name%"]/@connectionString');
              if db_connection_list then
                  db_connection := db_connection_list[0];
                  db_host     := regex.extract(db_connection, regex 'Data Source=([^\\]+)\\', raw '\1');
                  db_instance := regex.extract(db_connection, regex 'Data Source=[^\\]+\\([^;]+);', raw '\1');
                  if db_host and db_instance then
                      if db_host = '(local)' then
                          db_host := 'localhost';
                      end if;
                      db_server_sis := SearchFunctions.getSoftwareNodes(host, node_address := db_host,
                                                                        software_type := "Microsoft SQL Server",
                                                                        instance := db_instance, db_name := db_name);
                      if size(db_server_sis) = 1 then
                          model.uniquerel.Communication(Client := si_node, Server := db_server_sis[0]);
                      end if;
                  end if;
              end if;
          end if;
          xpath.closeDocument(config_file_content_xpath);
      end if;
  end if;
Was this page helpful? Yes No Submitting... Thank you

Comments