How to parse key's values from xml.data's parsed input

juicifer

New Member
I am having trouble figuring out what the elements are in parsed xml input, after I extract values using the :content key. Given the following parsed xml input, how can I extract the values for all the :content keys?#clojure.data.xml.Element{:tag :Header, :attrs {}, :content (#clojure.data.xml.Element{:tag :ExportType, :attrs {}, :content ("Tamper Export")} #clojure.data.xml.Element{:tag :CurrentDateTime, :attrs {}, :content ("2012-06-26T15:40:22.063")} #clojure.data.xml.Element{:tag :ScheduledDateTime, :attrs {}, :content ("2012-06-25T00:00:00")} #clojure.data.xml.Element{:tag :ExportGuid, :attrs {}, :content ("{06643D9B-DCD3-459B-86A6-D21B20A03576}")} #clojure.data.xml.Element{:tag :FractionalReadIndicator, :attrs {}, :content ("1")})}This output was created by parsing an xml file using data.xml, and then extracted using\[code\](first (:content parsed-xml-input))\[/code\]Thank you.The following is giving me only device type and device id, which is only part of :content in the xml file. \[code\]<DeviceId>80580608</DeviceId><DeviceType>43</DeviceType>\[/code\]\[code\](defn extract-inner-map-val "Returns a map of embedded :content tag and value." [item] (let [key-elem (-> item :content first) val-elem (-> item :content second)] [(-> key-elem :content first) (-> val-elem :content first)]))(defn extract-content-from-map "Accepts a sequence of values associated with a map key, and transforms them into a map of key/value pairs." [parsed-map] (into {} (map extract-inner-map-val (:content parsed-map))))\[/code\]
 
Back
Top