The background here is that, I’ve been hoping to get some projects done in Clojure for quite some time now and when the opportunity regarding the XML tree transformation presented itself - I jumped at it.
However, after trying many libraries like clojure.xml , clojure.zip.data.xml or xml-in - I haven’t really been able to successfully complete the roundtrip from mangeto1 XML -> android XML and back from android XML to mangento1 XML.
I’m not familiar with either the Android or Magento XML format. Your magenta example in particular seems to have some xml inside xml, encoded as a string. Is that really how it’s supposed to look?
I would urge you to look at enlive, it allows you to deal with xml using selectors not unlike CSS or XPath, except that selectors are just clojure vectors, e.g. [:body :#app :li].
Unfortunately the documentation to enlive is pretty terrible. The README is an absolute mess (skip the first several pages until you get to the section titled “older stuff”), and most docs you find focus on using it as a templating system. The main namespace is called net.cgrand.enlive-html although it just deals with Clojure xml data, …
There are several functions that will parse html/xml, although if you’re dealing with xml I would use clojure.xml/parse, the return value of that is perfectly suitable for use with select, at etc.
I hope that helps. If you’re still stuck I can write up a small example later.
I have since you response, started to explore enlive and I am slowly making my way through it’s API, trying to understand how I can apply it in my use case.
I never related it with XML but I’m happy to note that many methods just work in XML just fine and there’s even a namespace within enlive for XML !
@plexus, is there a way to query clojure data structures much like what enlive is doing for the html and `xml?
I have a hunch that datomic-free version could be used for achieving the same and previously, I’ve used lucid.query and lucid.mind to achieve much the same result. Still, I’d like to know the community’s opinion on this.