Home > Opalis > Opalis: working with XML-files

Opalis: working with XML-files

I personally don’t like to store hard coded values in any of my scripts. They limit your abilities for future use. it’s the same with Opalis so I decided to store my configuration in an XML-file.

1) create a new .xml-file and create a new tree

<?xml version="1.0" encoding="ISO-8859-1"?>

<config>

<domain>
  <FQDN>mydomain.local</FQDN>
</domain>

<USER>
  <DEFAULTPASS>PKeTR3ss1w2xS</DEFAULTPASS>
</USER>

</config>

2) Add a new object to your Policy: Utilities –> Query XML

Browse to the created XML-file and enter the XPath Query. (a full list of the syntax can be found at w3schools).
Click on the tab “Run Behavior”  and select ; to separate the returned fields.

3) Return the variables

You could use the “Split Fields” object from the Data Manipulation Integration Pack or write a small Powershell script. I tested both but used the latter for readability options.

Add a new object: System –> Run .NET Script and create a link between the XML-file and the .NET Script.

Select “PowerShell”  as type and copy the code below

# Get the returned string from the XML-file
# ----------------------------------------------------
$xml_string = "{Query result from "Get variables"}"

$strVars = $xml_string.split(';')

$domain = $strVars[0]

Click on the tab “Published Data” and add as many variables as possible. This Published Data can be used in linked objects. Click on Add…

P.S.: the results of the XML-file are returned in an array so $strVars[1] will return the second variable and so on …

4) use the Published data

Now I can use the variable in linked objects

Categories: Opalis Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.