1
我在這裏搜索了Google,結果沒有任何結果,所以我希望這裏的某個人能夠幫助我理解如何在以下示例中解析XML Header中的「href =」。Applescript XML Parse Header
<?xml version="1.0" encoding="UTF-8"?>
<foo version="2" href="/event/189" product="Server">
<name>The Name</name>
</foo>
這是我所知道的。要解析的XML文件中的元素「名」,我可以做到以下幾點:
set source_xml to choose file "Select your xml source"
set posix_source_xml to POSIX path of source_xml
tell application "System Events"
set xml_file to XML file posix_source_xml
tell xml_file
tell XML element "foo"
set name_value to value of XML element "name"
end tell
end tell
end tell
但如何在「富」獲得的「href =」頭值?我想這沒有成功:
set source_xml to choose file "Select your xml source"
set posix_source_xml to POSIX path of source_xml
tell application "System Events"
set xml_file to XML file posix_source_xml
tell xml_file
set foo_value to value of XML element "foo"
end tell
end tell
即使是沒有工作,我會想象它會返回 - 版本=「2」 HREF =「/事件/ 189」產品=「服務器」 - 而不僅僅是 - /事件/ 189。
任何援助,將不勝感激!
哎@ snwbrdr78這究竟是怎麼走?我的答案你有幸運嗎? – adamh