回复 1# zhengwei007
假设所有xml文件均在同1个文件夹下,用第3方工具gaw( http://bcn.bathome.net/tool/5.1.0/gawk.exe ),在命令行方式下,其实现方法如下:- awk -v"OFS=," "/^\t+<item>$/,/^\t+<\/item>$/{if(/Soul Crystal/)exist_id=1;if(/^\t+<ingredient count=\"1\" id=\"[0-9]+\" \/>$/)if(exist_id)A=gensub(/^\t+<ingredient count=\"1\" id=\"([0-9]+)\" \/>$/,\"\\1\",\"g\",$0);if(/^\t+<production count=\"1\" id=\"[0-9]+\" \/>$/)if(exist_id)print A,gensub(/^\t+<production count=\"1\" id=\"([0-9]+)\" \/>$/,\"\\1\",\"g\",$0);if(/^\t+<\/item>$/)exist_id=0}" *.xml>out.csv
复制代码
|