<cids>
<defect name="29237" action="decided" checker="OVERRUN_STATIC" cid="29237"/>
<defect ....
</cids>
I want to convert this xml to CSV I checked many links but didn't find any link where XML is converted to CSV by parsing attributes.
<cids>
<defect name="29237" action="decided" checker="OVERRUN_STATIC" cid="29237"/>
<defect ....
</cids>
I want to convert this xml to CSV I checked many links but didn't find any link where XML is converted to CSV by parsing attributes.
Windows command line
for /F tokens^=2^,4^,6^,8^ delims^=^" %a in ('type data.xml ^| find "<defect" ') do echo %a,%b,%c,%d >> data.csv
AWK (in this case, also from windows command line)
awk -F \" -v OFS=, "/^<defec/{print $2,$4,$6,$8}" data.xml > data.csv
In both cases, using quotes as delimiter to split records into fields.
As no language or anything was asked, this is a vim command (tested on vim 7.3 for windows)
%s/<defect \w\+="\(.\+\)" \w\+="\(.\+\)" \w\+="\(.\+\)" \w\+="\(.\+\)"\/>/\1,\2,\3,\4/g
THEN, delete the first and last line by hand.