For the past several days I've been trying to figure out how I can write a script to parse out what I assume is some pseudo XML file. The most I've come across is xmllint, but everything references xpath, which doesn't work for me. And I can't modify the box I'm running this on, I have to work with what I have already.
I say it's a "pseudo" XML because this is how it starts
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<policy name='Default' schema-version='1.2.3' valid='true' version='68.0.0' xmlns='http://www.iss.net/cml/NetworkObjects'>
<AddressGroupList Comment='Some Comment' Name='MyNetworks'>
<AddressGroup>
<AddressName value='Network1'/>
</AddressGroup>
<AddressGroup>
<AddressName value='Network2'/>
</AddressGroup>
<AddressGroup>
<AddressName value='Network3'/>
</AddressGroup>
<AddressGroup>
<AddressName value='Network4'/>
</AddressGroup>
</AddressGroupList>
Later on, in that same file, each "AddressName" item is defined, below is just one example
<AddressList Comment='US Access' GUID='8BFC30C4-31B6-4038-A507-A0D1712992AD' Name='Network1'>
<AddressMask IPAddressMask='1.2.3.0/24'/>
</AddressList>
I consider myself a pretty decent script writer, but I've always worked with flat text. I can't figure out how to parse things out of this XML type setup and I'm desperate for help.
I need to first parse out Name/comment/IPAddressMask to create host objects, and then go back and create the group objects to reference the hosts objects.
In an ideal world, my output would be something like
Name:Type:Comment:IP:Netmask
Network1:network:US Access:1.2.3.0:24
Then
Name:type:Comment;members
MyNetworks:Group:Some Comment;Network1, Network2, Network3, Network4
If anyone can help get me started in the right direction, I would be most appreciative.