how to extract data in nested list/vector clojure

烈酒焚心 提交于 2019-12-25 17:48:12

问题


I have parse xml and get the following result

(({:tag :Column,
   :attrs {:Name "VENDOR_KEY", :Type "Int", :NotNull "Yes"},
   :content nil}
  {:tag :Column,
   :attrs {:Name "RETAILER_KEY", :Type "Int", :NotNull "Yes"},
   :content nil}
  {:tag :Column,
   :attrs {:Name "ITEM_KEY", :Type "Int", :NotNull "Yes"},
   :content nil})
 ({:tag :Column,
   :attrs {:Name "Store_Key", :Type "Int", :NotNull "Yes"},
   :content nil}))

then how to convert it to the following, basically I want to extract the value of key :attrs in nested list.

    (
    ({:Name "VENDOR_KEY", :Type "Int", :NotNull "Yes"},
     {:Name "RETAILER_KEY", :Type "Int", :NotNull "Yes"},
     {:Name "ITEM_KEY", :Type "Int", :NotNull "Yes"}),
    ({:Name "Store_Key", :Type "Int", :NotNull "Yes"})
    )

回答1:


so yes right here your solution as hsestupin said

(map #(map :attrs %) result)

i am assuming result is your input data.



来源:https://stackoverflow.com/questions/29234253/how-to-extract-data-in-nested-list-vector-clojure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!