我有一個小問題,不知道從哪裏開始。 我有一個文本文件,其中包含以下信息。將文本格式化爲單獨的文件
MINI COOPER 2007, 30,000 miles, British Racing Green, full service history, metallic paint, alloys. Great condition. £5,995 ono Telephone xxxxx xxxxx
我需要填充上述信息的格式如下
<advert>
<manufacturer></manufacturer>
<make></make>
<model></make>
<price></price>
<miles></miles>
<image></image>
<desc><![CDATA[desc>
<expiry></expiry> // Any point in the future
<url></url> // Optional
</advert>
<advert>
輸出應該是。
</advert>
<advert>
<manufacturer>MINI</manufacturer>
<make></make>
<model></make>
<price>5,995</price>
<miles>30000</miles>
<image></image>
<desc><![CDATA[2007, British Racing Green, full service history, metallic paint, alloys. Great condition.Telephone xxxxxx xxxxxx]]></desc>
<expiry>Todays date 13/05/2013</expiry>
<url></url>
</advert>
任何幫助將創建讚賞。
一個'python'腳本,或者'gawk'腳本中使用'-F,'能有所幫助。你嘗試了什麼?沒有顯示你嘗試過的代碼,你將無法獲得幫助... – 2013-05-13 11:00:41
我曾經有人指點我在正確的方向.. – 2013-05-13 11:11:40
我確實指出了一些方向......但你必須學習足夠的關注他們。 – 2013-05-13 11:14:35