0

我正在尝试制作一个脚本来查找和替换一些 xml 结构。

我已经把它弄平了,没有空格,没有回报。

到目前为止,我已经做了:

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 ».

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

4

1 回答 1

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
于 2016-09-21T11:18:05.603 回答