   (let [fac (doto (javax.xml.stream.XMLInputFactory/newInstance)
               (.setProperty javax.xml.stream.XMLInputFactory/IS_COALESCING true))
         sreader (.createXMLStreamReader fac s)]
-    (pull-seq sreader)))
+    (doall (pull-seq sreader))))
 
 (defn parse
   "Convenience function. Parses the source, which can be a File,

    (.writeCharacters ^javax.xml.stream.XMLStreamWriter writer e)))

(defn element [tag & [attrs & content]]
  (Element. tag (or attrs {}) content))

(defn cdata [content]
  (CData. content))

  objects. See source-seq and parse."
  [events]
  (ffirst
   (seq-tree
    (fn [^Event event contents]
      (when (= :start-element (.type event))
        (Element. (.name event) (.attrs event) contents)))
    (fn [^Event event] (= :end-element (.type event)))
    (fn [^Event event] (.str event))
    events)))

(defprotocol AsElements
  (as-elements [expr] "Return a seq of elements represented by an expression."))
