Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Caution: I'm a noob when it comes to xml, but I gave it a try for fun. This is just an example of how you could navigate through the xml-file. :)</p> <p>XML file (test.xml):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;servers&gt; &lt;server&gt; &lt;servername&gt;server1&lt;/servername&gt; &lt;credential&gt;domain\user&lt;/credential&gt; &lt;batches&gt; &lt;batch&gt; &lt;batchname&gt;test&lt;/batchname&gt; &lt;batchpath&gt;e:\cit\sauvegarde\batch\recup.cmd&lt;/batchpath&gt; &lt;comment&gt;batch de test&lt;/comment&gt; &lt;schedule&gt; &lt;day&gt;lundi&lt;/day&gt; &lt;day&gt;mardi&lt;/day&gt; &lt;/schedule&gt; &lt;validations&gt; &lt;validation&gt; &lt;name&gt;log exist&lt;/name&gt; &lt;path&gt;\\smacweb\e$\cit\test.log&lt;/path&gt; &lt;filters&gt; &lt;filter&gt;NotNull&lt;/filter&gt; &lt;filter&gt;NotOlderThan,2&lt;/filter&gt; &lt;/filters&gt; &lt;/validation&gt; &lt;validation&gt; &lt;name&gt;no erros&lt;/name&gt; &lt;path&gt;\\smacweb\CIT\sauvegarde\logs\*.log&lt;/path&gt; &lt;filters&gt; &lt;filter&gt;NotContains,'error'&lt;/filter&gt; &lt;/filters&gt; &lt;/validation&gt; &lt;/validations&gt; &lt;/batch&gt; &lt;batch&gt; &lt;batchname&gt;mysql&lt;/batchname&gt; &lt;comment&gt;dump des bases mysql&lt;/comment&gt; &lt;schedule&gt; &lt;day&gt;lundi&lt;/day&gt; &lt;day&gt;mardi&lt;/day&gt; &lt;day&gt;vendredi&lt;/day&gt; &lt;/schedule&gt; &lt;validations&gt; &lt;validation&gt; &lt;name&gt;log exist&lt;/name&gt; &lt;path&gt;\\smacweb\e$\mysqldump\dump.zip&lt;/path&gt; &lt;filters&gt; &lt;filter&gt;NotNull&lt;/filter&gt; &lt;filter&gt;NotOlderThan,2&lt;/filter&gt; &lt;/filters&gt; &lt;/validation&gt; &lt;validation&gt; &lt;name&gt;zipOK&lt;/name&gt; &lt;path&gt;\\smacweb\e$\mysqldump\dump.zip&lt;/path&gt; &lt;filters&gt; &lt;filter&gt;Test-Zip&lt;/filter&gt; &lt;/filters&gt; &lt;/validation&gt; &lt;/validations&gt; &lt;/batch&gt; &lt;/batches&gt; &lt;/server&gt; &lt;/servers&gt; </code></pre> <p>Powershell-script to loop through servers and batches:</p> <pre><code>function test { $xml = [xml](Get-Content C:\Users\Frode\Desktop\test.xml) $servers = $xml.SelectNodes("/servers/server") foreach ($server in $servers) { $batches = $server.SelectNodes("batches/batch") Write-Host "Server: $($server.servername)" foreach ($batch in $batches) { Write-Host "Checking batch: $($batch.batchname)" } } } </code></pre> <p>Output:</p> <pre><code>PS-ADMIN C:\Windows\system32&gt; test Server: server1 Checking batch: test Checking batch: mysql </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload