This commit is contained in:
Adrien MALINGREY 2023-04-07 02:34:57 +02:00
parent d3b5a014e1
commit 7b66313c01

19
toxml.php Normal file
View File

@ -0,0 +1,19 @@
<?php
$yaml = yaml_parse_file($argv[1]);
$xml = new SimpleXMLElement("<lanScanConf></lanScanConf>");
foreach ($yaml as $groupName => $hosts) {
$xmlGroup = $xml->addChild("group");
$xmlGroup->addAttribute("name", $groupName);
if ($hosts) foreach ($hosts as $hostName => $services) {
$xmlHost = $xmlGroup->addChild("host");
$xmlHost->addAttribute("name", $hostName);
if ($services) foreach ($services as $service) {
$xmlHost->addChild("service");
$xmlHost->addAttribute("name", $service);
}
}
}
echo $xml->asXML();
?>