Thanks a bunch, this has been very helpful.
-- Dennis
On Wed, Dec 2, 2009 at 1:03 PM, Tayssir John Gabbour <
tayssir.j...@googlemail.com> wrote:
> BTW, I should point out that zip-filter.xml/xml-> is surprisingly
> syntaxy.
>
> (xml-> loc
>:CLUSTER :HOST :METRIC
> (fn [loc]
>
Thanks, I think I have the idea.
(ns ziptest
(:require [clojure.zip :as zip]
[clojure.xml :as xml]
[clojure.contrib.zip-filter :as zf])
(:use clojure.contrib.zip-filter.xml)
(:import (java.io ByteArrayInputStream)))
(def *xml-string*
"a1b1c1a1b1c2a1b2c1")
(defn string-to-zi
BTW, I should point out that zip-filter.xml/xml-> is surprisingly
syntaxy.
(xml-> loc
:CLUSTER :HOST :METRIC
(fn [loc]
[[(xml1-> (zip/up loc) (attr :NAME))
(xml1-> loc (attr :NAME))
(xml1-> loc (attr :VAL))
(xml1-> loc
Hi!
Taking minor liberties with your code (for clarity), the following
gives pretty much the same result as your handle-xml function:
(ns blah
(:require [clojure.xml :as xml]
[clojure.zip :as zip])
(:use clojure.contrib.zip-filter.xml))
(defn my-test []
(doseq [x (xml-> (zip/x
On Dec 2, 4:51 pm, Dennis wrote:
> The XML is of the form:
> ganglia
> multiple clusters
> multiple hosts
> multiple metrics
Use XPath. Seriously, I hate XML and XSLT, but XPath is simply the
most concise way to extract things from a nested structure. Most XPath-
libraries allow for p
On Wed, Dec 2, 2009 at 11:29 AM, Dennis wrote:
> Sean,
> I probably did not make it clear, but I am using parse. The second line of
> handle-xml function in my original E-Mail has the parse in it. I then
> iterate over the xml-seq.
Are you familiar with 'zippers'? There is a zipper for xml-seqs
Sean,
I probably did not make it clear, but I am using parse. The second line of
handle-xml function in my original E-Mail has the parse in it. I then
iterate over the xml-seq.
I am also using:
(ns zod
(:require [clojure.contrib.http.agent :as http])
(:import (java.util Timer TimerTask))
Try the clojure.xml namespace. There's a funciton parse in there that
should help.
On Dec 2, 10:51 am, Dennis wrote:
> Howdy,
>
> Being new to clojure, I am having a difficult time parsing XML in an elegant
> manner. I am pulling metric information from a ganglia server as XML and
> then parsin
Howdy,
Being new to clojure, I am having a difficult time parsing XML in an elegant
manner. I am pulling metric information from a ganglia server as XML and
then parsing it. The below function works but it makes me feel icky. I was
hoping for some tips.
The "dc" variable contains a map with so