Sponsored Content
Full Discussion: Script to group XML entries?
Top Forums Shell Programming and Scripting Script to group XML entries? Post 302769771 by dlundwall on Wednesday 13th of February 2013 10:28:48 AM
Old 02-13-2013
Understood. Here is the complete xml code:

Code:
<?xml version="1.0"?>
<GroupList>
 <Group version="1.0.0">
  <ID>39060</ID>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 19 16:20:34 PST 2012</CreateTime>
   <Name>San Jose, CA (SJC)</Name>
  </Item>
 </Group>
 <Group version="1.0.0">
  <ID>244</ID>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 12 16:47:02 PST 2012</CreateTime>
   <Name>Interfaces</Name>
   <Description>Includes interfaces from all data sources.</Description>
  </Item>
 </Group>
 <Group version="1.0.0">
  <ID>40151</ID>
  <RelatesTo>
   <MonitoringProfileIDList relatesURL="relatesto/monitoringprofiles" rootURL="monitoringprofiles">
    <ID>48717</ID>
   </MonitoringProfileIDList>
   <DeviceIDList relatesURL="relatesto/devices" rootURL="devices">
    <ID>56717</ID>
    <ID>56718</ID>
    <ID>56719</ID>
    <ID>56720</ID>
    <ID>56713</ID>
    <ID>56714</ID>
    <ID>56715</ID>
    <ID>56716</ID>
    <ID>56709</ID>
    <ID>56710</ID>
    <ID>39905</ID>
    <ID>39898</ID>
    <ID>39897</ID>
    <ID>39900</ID>
    <ID>39899</ID>
    <ID>39902</ID>
    <ID>56722</ID>
    <ID>39901</ID>
    <ID>56721</ID>
    <ID>39903</ID>
    <ID>56723</ID>
   </DeviceIDList>
  </RelatesTo>
  <IsAlso>
   <IsA name="MonitoredGroup" rootURL="monitoredgroups"/>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 26 16:03:53 PST 2012</CreateTime>
   <Name>Voice Call Center</Name>
  </Item>
  <MonitoredGroup version="0.0.0"/>
 </Group>
 <Group version="1.0.0">
  <ID>250</ID>
  <RelatesTo>
   <DeviceIDList relatesURL="relatesto/devices" rootURL="devices">
    <ID>18797</ID>
    <ID>18791</ID>
    <ID>18818</ID>
    <ID>18817</ID>
    <ID>18875</ID>
    <ID>18816</ID>
    <ID>18907</ID>
    <ID>18908</ID>
    <ID>18909</ID>
    <ID>18910</ID>
    <ID>18911</ID>
    <ID>18912</ID>
    <ID>18685</ID>
    <ID>18684</ID>
    <ID>18782</ID>
   </DeviceIDList>
  </RelatesTo>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 12 16:47:02 PST 2012</CreateTime>
   <Name>Pingable Devices</Name>
   <Description>This group contains all the pingable devices reported by each data source.</Description>
  </Item>
  <MonitoredGroup version="0.0.0">
   <RelatesTo>
    <DeviceIDList relatesURL="relatesto/devices" rootURL="devices">
     <ID>18797</ID>
     <ID>18791</ID>
     <ID>18818</ID>
     <ID>18817</ID>
     <ID>18875</ID>
     <ID>18816</ID>
     <ID>18907</ID>
     <ID>18908</ID>
     <ID>18909</ID>
     <ID>18910</ID>
     <ID>18911</ID>
     <ID>18912</ID>
     <ID>18685</ID>
     <ID>18684</ID>
     <ID>18782</ID>
    </DeviceIDList>
   </RelatesTo>
  </MonitoredGroup>
 </Group>
 <Group version="1.0.0">
  <ID>249</ID>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 12 16:47:02 PST 2012</CreateTime>
   <Name>Device Components</Name>
   <Description>This group contains all the device components reported by each data source.</Description>
  </Item>
 </Group>
 <Group version="1.0.0">
  <ID>39072</ID>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 19 16:25:36 PST 2012</CreateTime>
   <Name>Cairo, Egypt (CAI)</Name>
  </Item>
 </Group>
 <Group version="1.0.0">
  <ID>39786</ID>
  <RelatesTo>
   <MonitoringProfileIDList relatesURL="relatesto/monitoringprofiles" rootURL="monitoringprofiles">
    <ID>48717</ID>
   </MonitoringProfileIDList>
   <DeviceIDList relatesURL="relatesto/devices" rootURL="devices">
    <ID>18913</ID>
    <ID>18680</ID>
    <ID>18815</ID>
    <ID>18914</ID>
    <ID>18814</ID>
    <ID>18811</ID>
    <ID>18809</ID>
    <ID>18810</ID>
    <ID>18808</ID>
    <ID>85847</ID>
    <ID>18681</ID>
    <ID>39903</ID>
   </DeviceIDList>
  </RelatesTo>
  <IsAlso>
   <IsA name="MonitoredGroup" rootURL="monitoredgroups"/>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 26 10:51:43 PST 2012</CreateTime>
   <Name>Las Vegas SERVERS</Name>
   <Description>All servers found in Las Vegas</Description>
  </Item>
  <MonitoredGroup version="0.0.0"/>
 </Group>
 <Group version="1.0.0">
  <ID>227</ID>
  <IsAlso>
   <IsA name="SyncableGroup" rootURL="syncablegroup"/>
   <IsA name="Syncable" rootURL="syncable"/>
  </IsAlso>
  <Syncable version="1.0.0"/>
  <Item version="1.0.0">
   <CreateTime>Mon Nov 12 16:47:02 PST 2012</CreateTime>
   <Name>All Groups</Name>
   <Description>Includes every group and item type defined within the performance center.</Description>
  </Item>
 </Group>

So, in the above example xml file at the end you have Group ID 39786 which references to "Las Vegas SERVERS". The DeviceIDList are the ID's that correspond to the devices in ANOTHER xml file. So in the case above, I am trying to get output like:

Group Info: Las Vegas SERVERS (39786)
Devices in group:
lv-svr01-fs1 (18913)
lv-svr01-fs2 (18680)
lv-svr02-nx1 (18815)
lv-svr03-nx1 (18914)
...
Total in group: 12
 

9 More Discussions You Might Find Interesting

1. Solaris

entry in /etc/group too long - problem using sudo with %group

hi folks, I've been googling for quite some time, but still can't find anything near it...my problem is the following: for useradministration in our company we are using ssh/sudo, now whenever I try to add users (we have quite a number of users) with useradd -G groupname for secondary group I... (4 Replies)
Discussion started by: poli
4 Replies

2. Shell Programming and Scripting

How to remove xml namespace from xml file using shell script?

I have an xml file: <AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Table1> <Data1 10 </Data1> <Data2 20 </Data2> <Data3 40 </Data3> <Table1> </AutoData> and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only. I tried using sed... (10 Replies)
Discussion started by: Gary1978
10 Replies

3. Shell Programming and Scripting

Merge group numbers and add a column containing group names

I have a file in the following format. Groups of data merge together and the group number is indicated above each group. 1 adrf dfgr dfg 2 dfgr dfgr 3 dfef dfr fd 4 fgrt fgr fgg 5 fgrt fgr (3 Replies)
Discussion started by: Lucky Ali
3 Replies

4. Shell Programming and Scripting

Merge group numbers and add a column containing group names

Hi All I do have a file like this with 6 columns. Groups of data merge together and the group number is indicated above each group. 1 1 12 26 289 3.2e-027 GCGTATGGCGGC 2 12 26 215 6.7e+006 TTCCACCTTTTG 3 9 26 175 ... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

5. Shell Programming and Scripting

Sort the file contents in each group....print the group title as well

I've this file and need to sort the data in each group File would look like this ... cat file1.txt Reason : ABC 12345-0023 32123-5400 32442-5333 Reason : DEF 42523-3453 23345-3311 Reason : HIJ 454553-0001 I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Discussion started by: prash184u
11 Replies

6. AIX

Adding a Volume Group to an HACMP Resource Group?

Hi, I have a 2 node Cluster. Which is working in active/passive mode (i.e Node#1 is running and when it goes down the Node#2 takes over) Now there's this requirement that we need a mount point say /test that should be available in active node #1 and when node #1 goes down and node#2 takes... (6 Replies)
Discussion started by: aixromeo
6 Replies

7. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies

8. Shell Programming and Scripting

Shell script - group by

Hi, I have text file as shown below. root 25 oracle 25 batch 30 griduser 32 admin 35 root 25 oracle 25 batch 30 griduser 32 oracle 25 batch 30 griduser 32 xuser 45 admin 35 I want to group by based on user name, and the output need to be as below. Not necessary the username to be... (10 Replies)
Discussion started by: baladelaware73
10 Replies

9. Programming

Sql ORA-00937: not a single-group group function

I'm trying to return only one row with the highest value for PCT_MAX_USED. Any suggestions? When I add this code, I get the ORA-00937 error. trunc(max(decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100))) pct_max_used This is the original and returns all rows. select (select... (3 Replies)
Discussion started by: progkcp
3 Replies
All times are GMT -4. The time now is 03:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy