如何在嵌套列表/向量Clojure中提取数据 [英] how to extract data in nested list/vector clojure
本文介绍了如何在嵌套列表/向量Clojure中提取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我解析了xml并得到以下结果
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}))
然后将其转换为以下,基本上我想提取嵌套列表中key:attrs的值。
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"})
)
推荐答案
是的,在这里,您的解决方案为
hsestupin 说
so yes right here your solution as hsestupin said
(map #(map :attrs %) result)
我假设结果是您的输入数据。
i am assuming result is your input data.
这篇关于如何在嵌套列表/向量Clojure中提取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文