clojure.core/xml-seq¶ View this page on ClojureDocs Type: function Added: Clojure 1.0 Examples: 3 Runnable: 0 ([root]) A tree seq on the xml elements as per xml/parse Examples¶ by ed-g on 2013-01-11 . May have evaluation errors. ▶ ;; data.xml from https://github.com/clojure/data.xml/ (use '[clojure.data.xml :only [parse-str]]) (let [xml-text "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <foo key=\"val\">1<bar>2</bar>3</foo>"] (let [root (parse-str xml-text)] (xml-seq root))) ({:tag :foo, :attrs {:key "val"}, :content ("1" {:tag :bar, :attrs {}, :content ("2")} "3")} "1" {:tag :bar, :attrs {}, :content ("2")} "2" "3") by biggert on 2013-05-02 . May have evaluation errors. ▶ (use '[clojure.data.xml :only [parse]]) ;; clojure.xml/parse requires string to be ByteArrayInputStream (let [xml-text "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <foo key=\"val\">1<bar>2</bar>3</foo>"] (let [input (java.io.ByteArrayInputStream. (.getBytes xml-text))] (let [root (parse input)] (xml-seq root)))) ({:tag :foo, :attrs {:key "val"}, :content ("1" {:tag :bar, :attrs {}, :content ("2")} "3")} "1" {:tag :bar, :attrs {}, :content ("2")} "2" "3") by reborg on 2018-02-22 . May have evaluation errors. ▶ ;; Any breaking news today? (require '[clojure.java.io :as io]) (require '[clojure.xml :as xml]) (def feeds [[:guardian "https://www.theguardian.com/world/rss"] [:wash-post "http://feeds.washingtonpost.com/rss/rss_blogpost"] [:nytimes "https://rss.nytimes.com/services/xml/rss/nyt/World.xml"] [:wsj "https://feeds.a.dj.com/rss/RSSWorldNews.xml"] [:reuters "http://feeds.reuters.com/reuters/UKTopNews"]]) (pmap (fn [[feed url]] (let [content (comp first :content)] [feed (sequence (comp (filter (comp string? content)) (filter (comp #{:title} :tag)) (filter #(re-find #"(?i)breaking" (content %))) (map content)) (xml-seq (xml/parse url)))])) feeds) ;; Only a false positive... ;;([:guardian ("Climate change 'will push European cities towards breaking point'")] ;; [:wash-post ()] ;; [:nytimes ()] ;; [:wsj ()] ;; [:reuters ()]) Content from the matching ClojureDocs page, with authors credited on each contribution.