Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The above answer works, but I find it a lot easier to use <code>clojure.data.zip.xml</code> (used to be <code>clojure-contrib.zip-filter.xml</code> prior to Clojure 1.3).</p> <p>file:</p> <p><code>myfile.xml</code>:</p> <pre><code>&lt;songs&gt; &lt;track id="t1"&gt;&lt;name&gt;Track one&lt;/name&gt;&lt;/track&gt; &lt;track id="t2"&gt;&lt;name&gt;Track two&lt;/name&gt;&lt;/track&gt; &lt;/songs&gt; </code></pre> <p>code:</p> <pre><code>; Clojure 1.3 (ns example (:use [clojure.data.zip.xml :only (attr text xml-&gt;)]) ; dep: see below (:require [clojure.xml :as xml] [clojure.zip :as zip])) (def xml (xml/parse "myfile.xml")) (def zipped (zip/xml-zip xml)) (xml-&gt; zipped :track :name text) ; ("Track one" "Track two") (xml-&gt; zipped :track (attr :id)) ; ("t1" "t2") </code></pre> <p>Unfortunately, you need to pull in a dependency on <a href="https://github.com/clojure/data.zip" rel="nofollow noreferrer">data.zip</a> to get this nice read/filter functionality. <strong>It's worth the dependency :)</strong> In <a href="https://github.com/technomancy/leiningen" rel="nofollow noreferrer">lein</a> it would be (as of 17-Aug-2013):</p> <pre><code>[org.clojure/data.zip "0.1.1"] </code></pre> <p>And as for docs for <code>data.zip.xml</code> ... I just look at the relatively small source file <a href="https://github.com/clojure/data.zip/blob/master/src/main/clojure/clojure/data/zip/xml.clj" rel="nofollow noreferrer">here</a> to see what is possible. Another good SO answer <a href="https://stackoverflow.com/a/6471118/69689">here</a>, too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload