I have a data like below How to print the data which is between two tags I want the data to be command-separated csv format
My approach was to convert data to horizontal format and then cut after every 4th column and convert to vertical
Data in xml file
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-
<sst uniqueCount="12" count="12"
xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
-
<si>
<t>"NAME"</t>
</si>
-
<si>
<t>"Vikas"</t>
</si>
-
<si>
<t>"Vijay"</t>
</si>
-
<si>
<t>"Vilas"</t>
</si>
-
<si>
<t>"AGE"</t>
</si>
-
<si>
<t>"24"</t>
</si>
-
<si>
<t>"34"</t>
</si>
-
<si>
<t>"35"</t>
</si>
-
<si>
<t>"COURSE"</t>
</si>
-
<si>
<t>"MCA"</t>
</si>
-
<si>
<t>"MMS"</t>
</si>
-
<si>
<t>"MBA"</t>
</si>
</sst>
I have tried this below command not working ..
awk '/<t/{flag=1;next}/<t/{flag=0}flag' abc.xml
Even tried this below command , it gives data but in single line
awk -F'(</*t>|</*t>)' 'NF>1{for(i=2;i<NF; i=i+2) printf("%s%s", $i, (i+1==NF)?ORS:OFS)}' OFS=',' demo.xml
I want below data as output
NAME,AGE,Course
Vikas,"25",MCA
Prabhash,"34",MBA
Arjun,"21",MMS