This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-11
Channels
- # announcements (1)
- # beginners (67)
- # calva (4)
- # cider (6)
- # clj-kondo (26)
- # clojure (61)
- # clojure-belgium (2)
- # clojure-sweden (1)
- # clojurescript (12)
- # community-development (27)
- # cursive (2)
- # datascript (4)
- # datomic (20)
- # emacs (4)
- # funcool (1)
- # graphql (11)
- # honeysql (3)
- # malli (15)
- # membrane (6)
- # nbb (4)
- # nextjournal (7)
- # pathom (8)
- # polylith (7)
- # rdf (1)
- # re-frame (1)
- # releases (2)
- # shadow-cljs (42)
- # specter (3)
- # tools-deps (25)
- # xtdb (17)
I'm trying to transform an XML tree, like the following:
(def xml {:tag :main,
:attrs {},
:content
["\n "
{:tag :parent,
:attrs {},
:content
["\n "
{:tag :child1, :attrs {}, :content ["value1"]}
"\n "
{:tag :child2, :attrs {}, :content ["value2"]}
"\n "
{:tag :child3, :attrs {}, :content ["value3"]}
"\n "]}
"\n "
{:tag :parent,
:attrs {},
:content
["\n "
{:tag :child1, :attrs {}, :content ["value4"]}
"\n "
{:tag :child2, :attrs {}, :content ["value5"]}
"\n "
{:tag :child3, :attrs {}, :content ["value6"]}
"\n "
{:tag :child4, :attrs {}, :content []}
"\n "]}
"\n "
{:tag :parent, :attrs {}, :content []}
"\n"]})
into a flat data structure like:
(def flat-xml [{[:main :parent :child1] "value1"
[:main :parent :child2] "value2"
[:main :parent :child3] "value3"}
{[:main :parent :child1] "value4"
[:main :parent :child2] "value5"
[:main :parent :child3] "value6"
[:main :parent :child4] ""}])
could this be done using specter?I would also check out: https://github.com/turtlegrammar/faconne it's pretty awesome at doing you are looking to do
@nyor.tr yes, you would use recursive-path
and collect-one