2016-08-03 72 views
0

我试图做一个脚本,将查找和替换一些XML结构。查找和替换为textWrangler脚本

我已经完全平坦,没有空间,没有回报。

到目前为止,我已经做:

tell application "TextWrangler" 
    replace text "<key>amenity</key><string>drinking_water</string>" using text "<key>ico</key> 
<string>NPpotableGPS30</string>" 
end tell 

脚本编辑说:

Error in TextWrangler : text "<key>amenity</key><string>drinking_water</string>" don't have the message « replace ». 

这是我的第一个剧本,所以我可能做错事,但什么?

回答

2

关键“text”似乎错位。下面看起来正确工作(根据实际工作情况,从searching开始的顺序是可选的,用于定义要处理的文档):

tell application "TextWrangler" 
replace "<key>amenity</key><string>drinking_water</string>" using "<key>ico</key><string>NPpotableGPS30</string>" searching in text 1 of text document "..." options {search mode:grep, starting at top:true} 
end tell 
tell application "TextWrangler" 
replace "<key>amenity</key><string>drinking_water</string>" using "<key>ico</key><string>NPpotableGPS30</string>" searching in text 1 of text document "..." options {search mode:grep, starting at top:true} 
end tell