Skip to content

Instantly share code, notes, and snippets.

@bzg
Last active April 13, 2017 07:17
Show Gist options
  • Save bzg/a35c4f986583e490480b5932d601ffed to your computer and use it in GitHub Desktop.
Save bzg/a35c4f986583e490480b5932d601ffed to your computer and use it in GitHub Desktop.
Make xml-> return empty strings instead of skipping non-matching nodes
(ns test
(:require [clojure.zip :as zip]
[clojure.data.xml :as xml]
[clojure.data.zip.xml :as zx]))
(def xml-example
"<top>
<id>
<desc>
<other>Something</other>
<desc>A description</desc>
</desc>
</id>
<id>
<desc>
<desc>Another description</desc>
</desc>
</id>
</top>")
(zx/xml-> (zip/xml-zip (xml/parse-str xml-example))
:top :id :desc :other zx/text)
;; Returns ("Something") while I would like ("Something" "")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment