Hi,
I have a xml script, I converted it to .txt with values comma seperated using awk function. But I want the output values should be inside double quotes
My xml script (Workorders.xml) is shown like below:
<?xml version="1.0" encoding="utf-8" ?>
<scbm-extract version="3.3">
<workOrderList>
<workOrder>
<workOrderCode>313194073</workOrderCode>
<branchCode>2021:1206</branchCode>
<demand></demand>
<demandLineItem></demandLineItem>
<priority></priority>
<completionDate>2016-07-10T08:00:00</completionDate>
</workOrder>
-----------------------------------------------------------------------------
I used the below awk command to do this (awk script copied from previous posts)
awk -f jobxml.awk WorkOrders.xml
jobxml.awk
BEGIN { FS="[<>]"; OFS="," }
# Single close-tag
(NF==3) && /^[ \t]*<[/]/ {
$0=""
if(!TITLE) # Print a title line
{
for(N=1; N<=L; N++) $N=T[N]
print
TITLE=1
}
for(N=1; N<=L; N++) { $N=A[T[N]]; delete A[T[N]] }
print
}
$2 && $4 && ($2 == substr($4, 2)) {
if(!T[$2]) { T[$2]=++L; T[L]=$2 } # Save titles for later
gsub(/^[ \t]*/, "", $3); # Get rid of spaces in data
gsub(/[ \t]*$/, "", $3);
A[$2]=$3 # Save for later
}
Output comes like below:
workOrderCode,branchCode,demand,demandLineItem,priority,completionDate
313194073,2021:1206,,,,2016-07-10T08:00:00
I want to show output like below. ie output values with double quotes
workOrderCode,branchCode,demand,demandLineItem,priority,completionDate
"313194073","2021:1206","","","","2016-07-10T08:00:00"
Please help me on this
Thanks,
Viswa