How to extract data from xml file using shell scripting?

Hi evry1,
This is my 1st post in this forum.Pls help me

I want to extract some data froma xml file which has 2000 lines using shell scripting. Actually my xml file has some "audio and video codes" which i need to arrange in a column wise format after extracting it using shell scripting.I cant put the data manually as it will take much time ..
pls help Experts ...

Thanks in advance

Hello,

Could you please post your input code as well as your expected output on same. We will try to help on same.

Thanks,
R. Singh

Thanks for replying Mr Singh..

The input code is

 TimeStamp="1234567890" Data="t2u A 2 9020 585269098"/>
 TimeStamp="1234567890" Data="t2uX 2 9020 585269098"/>
 TimeStamp="1234567892" Data="t2u A 1 9000 585269099"/>
<TimeStamp="1234567892" Data="t2u X 1 9000 585269099"/>
TimeStamp="1234567894" Data="t6u X 192 9000 111883500"/>
TimeStamp="1374201903" Data="t6u A 192 9000 111883500"

And i want it to arrange it by column wise :

  Timestamp     t2u     t6u    A   X    9020 
 
1.1234567890   t2u             A         9020
2.1234567890    t2u                  X   9020
3.
4.
5..
6.

Thanks in advance

Hello,

Could you please try as follows command. Also let us say we have a fike named test where all data is stored.

Note: Please use code tags it's a good practice, also refer the Forum rules for same.

$  awk '{ printf "%-30s %-20s %s\n", $1, $2, $3 }' test
TimeStamp="1234567890"         Data="t2u            A
TimeStamp="1234567890"         Data="t2uX           2
TimeStamp="1234567892"         Data="t2u            A
<TimeStamp="1234567892"        Data="t2u            X
TimeStamp="1234567894"         Data="t6u            X
TimeStamp="1374201903"         Data="t6u            A
$

$

Thanks,
R. Singh

For the pattern you pasted, try this...

awk '-F"' '{split($4,o,/ /);print NR"."$2" "o[1]" "o[2]" "o[4]}' input_file

--ahamed