Daniel Wu
Daniel Wu

Reputation: 6003

how to extract data in nested list/vector clojure

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"})
    )

Upvotes: 0

Views: 660

Answers (1)

piyushmandovra
piyushmandovra

Reputation: 4381

so yes right here your solution as hsestupin said

(map #(map :attrs %) result)

i am assuming result is your input data.

Upvotes: 2

Related Questions