1
在Applescript中,是否有一種方法僅基於標記屬性來抓取標記塊?例如,我只想抓取具有與其關聯的屬性'style'的標記塊。 (我包括縮短XML)用Applescript解析XML並根據xml屬性引用標記塊
shortened xml file:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<templateDescription>
<toolbars>
<toolbarControls style="textToolbar">
</toolbarControls>
<toolbarControls style="textToolbar">
</toolbarControls>
<toolbarControls definition="image">
</toolbarControls>
</toolbars>
</templateDescription>
set XMLFile to "Macintosh HD:Users:<user>:Desktop:templateDescription.xml"
tell application "System Events"
set toolbarControls to XML elements of XML element "toolbars" of XML element 1 of contents of XMLFile
return every item of toolbarControls whose value of XML attribute "style" of XML element "toolbarControls" of XML element "toolbars" of XML element 1 of contents of XMLFile is "textToolbar"
end tell
*新的併發症:所以,我才意識到,有些個XML使用意見,並有一個與系統事件如不能正確解析XML時,有評論一個已知的bug。有沒有辦法解決這個問題?
感謝這麼多jackjr300。完全合作。 – thizzle