使用成員函數這是我的代碼:方案
(define p (read(open-input-file "starbucks4.sxml")))
(define get-artifacts
(lambda (l)
(member (list 'opm:artifact) l)))
(get-artifacts p)
我被告知,該成員函數在整個名單完全搜索。 .sxml文檔中有一個複雜的列表,其中包含許多稱爲「opm:artifact」的元素,但此方法返回#f且不包含列表。
任何人都可以看到我做錯了什麼?
樣品.sxml文件:
(opm:account ((ref "detailedAccount")))
"\n "
(opm:label ((value "Provide other Beverage")))
"\n ")
"\n ")
"\n "
(opm:artifacts
()
"\n "
(opm:artifact
((id "a1"))
"\n "
(opm:account ((ref "detailedAccount")))
"\n "
(opm:label ((value "order")))
"\n ")
"\n "
(opm:artifact
((id "a2"))
"\n "
(opm:account ((ref "detailedAccount")))
"\n "
(opm:label ((value "cash")))
"\n ")
"\n "
我試圖尋找所有的OPM:文物和相關的數據(它的子表)。
謝謝!我會如何搜索符號opm:神器? – Alex 2010-10-26 19:34:18
@Alex:'(deep-search'opm-artifact p)'注意這隻會返回true或false。如果你需要更多,需要修改一下。 – sepp2k 2010-10-26 19:43:08
@Alex:另外請注意,對於示例文件,您顯示'p'將只包含'(opm:account((ref'detailedAccount「))),因爲'read'只讀取一個表單。 – sepp2k 2010-10-26 19:44:34