I have some output in some structured data format that I need to convert into XML.
My use case is that Palo Alto firewalls deliver configuration output via the command line interface which cannot be used for restoring the configuration. It needs to be converted into XML to be able to use it.
The format is (just a snippet of the huge file to get the idea):
unknown-applications {
unknown-tcp {
destinations-per-hour 10;
sessions-per-hour 10;
session-length {
maximum-bytes 100;
minimum-bytes 50;
}
}
unknown-udp {
destinations-per-hour 10;
sessions-per-hour 10;
session-length {
maximum-bytes 100;
minimum-bytes 50;
}
}
}
and needs to be
<unknown-applications>
<unknown-tcp>
<destinations-per-hour>10</destinations-per-hour>
<sessions-per-hour>10</sessions-per-hour>
<session-length>
<maximum-bytes>100</maximum-bytes>
<minimum-bytes>50</minimum-bytes>
</session-length>
</unknown-tcp>
<unknown-udp>
<destinations-per-hour>10</destinations-per-hour>
<sessions-per-hour>10</sessions-per-hour>
<session-length>
<maximum-bytes>100</maximum-bytes>
<minimum-bytes>50</minimum-bytes>
</session-length>
</unknown-udp>
</unknown-applications>
Is there something like a parser to achieve this?
EDIT: as comments didnt allow me to post this much: thanks, looks promising!
some parts are not converted right because i didnt list an example for it: e.g.
import {
network {
interface [ ethernet1/5 ethernet1/6];
}
}
gets converted to
<import>
<network>
<interface>[</interface>
</network>
</import>
but should be
<import>
<network>
<interface>
<member>ethernet1/5</member>
<member>ethernet1/6</member>
</interface>
</network>
</import>
i see that there are some specific things like [] making it members, so i am not sure how feasible it is to do it manually... the original format is supposed to be in xml as well