1
我一直在抨擊這件事,它可能是一些平庸的事情(或不是)。這裏是 - 我想從xml中提取一些值。下面是我的程序(它需要重構,這是一個工作版本)在REPL(創建-地圖的事件)是給我一個了java.lang.RuntimeExceptionClojure:使用拉鍊從xml中提取價值
(ns datamodel
(:import (java.io ByteArrayInputStream))
(:use
[net.cgrand.enlive-html :as en-html ])
(:require
[clojure.zip :as z]
[clojure.data.zip.xml :only (attr text xml->)]
[clojure.xml :as xml ]
[clojure.contrib.zip-filter.xml :as zf]
))
(def data-url "http://api.eventful.com/rest/events/search?app_key=4H4Vff4PdrTGp3vV&keywords=music&location=Belgrade&date=Future")
(defstruct event :event-name :performers :start-time :stop-time)
(defn get-events [xz]
(map (juxt #(zf/xml1-> % (:title text))
#(zf/xml1-> % (:performers :performer :name text))
#(zf/xml1-> % (:start_time text))
#(zf/xml1-> % (:stop_time text)))
(zf/xml-> xz :events :event)))
(defn create-map-of-events []
(map #(apply struct event %) (get-events (z/xml-zip (xml/parse "http://api.eventful.com/rest/events/search? app_key=4H4Vff4PdrTGp3vV&keywords=music&location=Belgrade&date=Future")))))
:顯示java.lang.NullPointerException
我在做什麼xml1->錯?