我正在尝试获取一些 xml 代码,示例如下:
<time_report>
<project_ID>4</project_ID>
<project_status>close</project_status>
<client_ID>6001</client_ID>
<time_record>
<project_start_time>15:02:33</project_start_time>
<project_end_time>15:07:44</project_end_time>
<project_total_time>PT00H05M11S</project_total_time>
</time_record>
<employee_ID>10001</employee_ID>
<employee_name>Mary Beth</employee_name>
<date_created>2009-08-25</date_created>
</time_report>
然后输出它,使其格式如下:
project_id, project_status, client_id, project_start_time, project_end_time, project_total_time, employee_ID, employee_name, date_created
4, close, 6001, 15:02:33, 15:07:44, PT00H05M11S, 10001, Mary Beth, 2009-08-25
我一直在尝试使用 xmllint 来执行此操作,但不幸的是无法取得任何进展,我说我想知道是否有人会对我应该做什么提出建议?我将在 bash/shell 环境中执行此操作。任何帮助将不胜感激,谢谢!
还忘了提到如果我在excel中打开xml文件然后另存为csv,我可以得到正确的结果,只是想在linux中寻找一种方法
project_ID,project_status,client_ID,project_start_time,project_end_time,project_total_time,employee_ID,employee_name,date_created
4,close,6001,15:02:33,15:07:44,PT00H05M11S,10001,Mary Beth,8/25/2009
5,open,6003,12:00:00,12:45:00,PT00H45M00S,10003,Michelle,9/11/2009
2,close,6002,10:00:00,10:30:00,PT00H30M00S,10002,Joe,8/25/2009
2,open,6004,12:00:00,3:27:05,PT03H23M05S,10004,Mike,8/13/2009