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