Extract data from XML using ksh script

Sanehouse

New Member
The first question I asked on this topic was closed because of lack of info. So asking this again with some more details added.I have to extract a value given in one tag from a xml file and I have to do it using ksh (I can solve this in perl but I have to do it ksh, cannot use third party tools like xmlsh)sample.xml\[code\]<?xml version="1.0" standalone="yes" ?><parent_one> <parent_two> <Pool> <pool_name>ABC</pool_name> <percent_full>79</percent_full> <pool_state>Enabled</pool_state> </Pool> <Pool> <pool_name>DEF</pool_name> <percent_full>40</percent_full> <pool_state>Enabled</pool_state> </Pool> <Pool> <pool_name>XYZ</pool_name> <percent_full>40</percent_full> <pool_state>Disabled</pool_state> </Pool> <Totals> <total_tracks>4546456</total_tracks> <percent_full>48</percent_full> </Totals> </parent_two></parent_one>\[/code\]The ksh script should read sample.xml and print ABC, DEF from pool_name tag because the corresponding pool_state tag is enabled. It should not print XYZ because its pool_state tag is disabled.The ksh script would read sample.xml and output the followingABCDEFIs this feasible in ksh or do I have to use perl for this?
 
Top