data.zip

Not returning expected result for 'tag='

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:

Description

With this raw data:
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<result>\n <status>success</status>\n <message>success</message>\n <format>xml</format>\n <language>en</language>\n <ip>208.67.220.220</ip>\n <country_code>US</country_code>\n <country>United States</country>\n <region>California</region>\n <city>San Francisco</city>\n <latitude>37.7757</latitude>\n <longitude>-122.3952</longitude>\n <zip_code>94107</zip_code>\n <timezone>-08:00</timezone>\n <localtime>2014-04-17 06:52:45</localtime>\n</result>\n"

And resulting parse/zipper (def _sd ...)
[{:tag :result, :attrs nil, :content [{:tag :status, :attrs nil, :content ["success"]} {:tag :message, :attrs nil, :content ["success"]} {:tag :format, :attrs nil, :content ["xml"]} {:tag :language, :attrs nil, :content ["en"]} {:tag :ip, :attrs nil, :content ["208.67.220.220"]} {:tag :country_code, :attrs nil, :content ["US"]} {:tag :country, :attrs nil, :content ["United States"]} {:tag :region, :attrs nil, :content ["California"]} {:tag :city, :attrs nil, :content ["San Francisco"]} {:tag :latitude, :attrs nil, :content ["37.7757"]} {:tag :longitude, :attrs nil, :content ["-122.3952"]} {:tag :zip_code, :attrs nil, :content ["94107"]} {:tag :timezone, :attrs nil, :content ["-08:00"]} {:tag :localtime, :attrs nil, :content ["2014-04-17 06:52:45"]}]} nil]

The following returns nil:

NS (:require [clojure.data.zip.xml :as dzx])
(dzx/xml1-> _sd (dzx/tag= :result))
(dzx/xml1-> _sd (dzx/tag= :result) (dzx/tag= :status) dzx/text)

But this works:
(dzx/xml1-> _sd (dzx/tag= :ip) dzx/text)
"208.67.220.220"

Activity

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: