Example: xml-zip [skip ci]
This commit is contained in:
parent
17f35b4d48
commit
ec479f049a
2 changed files with 17 additions and 0 deletions
|
|
@ -300,6 +300,8 @@ $ examples/which.clj rg
|
|||
A script to retrieve the version from a `pom.xml` file. See
|
||||
[pom_version_get.clj](pom_version_get.clj). Written by [@wilkerlucio](https://github.com/wilkerlucio).
|
||||
|
||||
See [pom_version_get_xml_zip.clj](pom_version_get_xml_zip.clj) for how to do the same using zippers.
|
||||
|
||||
Also see [pom_version_set.clj](pom_version_set.clj) to set the pom version.
|
||||
|
||||
## Whatsapp frequencies
|
||||
|
|
|
|||
15
examples/pom_version_get_xml_zip.clj
Normal file
15
examples/pom_version_get_xml_zip.clj
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
(require '[babashka.deps :as deps])
|
||||
|
||||
(deps/add-deps '{:deps {org.clojure/data.zip {:mvn/version "RELEASE"}}})
|
||||
|
||||
(require '[clojure.data.xml :as xml]
|
||||
'[clojure.data.zip.xml :as xmlz]
|
||||
'[clojure.zip :as zip])
|
||||
|
||||
(def xml "<pom><version>1.0.0</version></pom>")
|
||||
|
||||
(-> xml
|
||||
xml/parse-str
|
||||
zip/xml-zip
|
||||
(xmlz/xml1-> :pom :version zip/down zip/node))
|
||||
;; => 1.0.0
|
||||
Loading…
Reference in a new issue