<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    J2EE之巔

     

    Clojure XPath

    The functions to support using XPath in Clojure.

    Source Code

     1 ;The code was implemented by caichao@amazon.com
     2 ;You could use the code anyway, but should keep the comments
     3 ;Created 2012.10
     4 (ns clojure.ccsoft.xml
     5   (:require [clojure.xml :as xml]))
     6  
     7 (import '(java.io StringReader)
     8         '(java.io ByteArrayInputStream))
     9  
    10 (defn xml-structure [xml-txt] 
    11    [ (xml/parse (-> xml-txt
    12               (.getBytes)
    13               (ByteArrayInputStream.)
    14      )
    15     )]
    16 )
    17  
    18 (defn node [tag xmlStruct]
    19  
    20   (first (filter #(= (:tag %) tag) (:content xmlStruct)))
    21 )
    22  
    23 (defn node [path xml-txt]
    24    (loop [path path 
    25           xml-content (xml-structure xml-txt) 
    26           ]
    27       (let [current-tag (first path) current-elem (first xml-content)]
    28         (if (= (:tag current-elem ) current-tag)
    29  
    30           (if (= (count path) 1)
    31             current-elem 
    32             (recur  (rest path) (:content current-elem ))
    33           )
    34           (if (> (count  xml-content) 1)
    35            (recur path  (rest xml-content))
    36           )
    37         )
    38      )
    39     )
    40  )

    How to Use

    (def cmd-example "<command>
                       <header>
                         
    <type>script</type>
                         
    <transaction_id>12345</transaction_id>
                       
    </header>
                       
    <body>
                          println 
    3+4;
                       
    </body>
                      
    </command>")
     
     
    (node [:command :header :transaction_id] cmd
    -example)


    posted on 2012-10-15 10:15 超越巔峰 閱讀(2880) 評論(0)  編輯  收藏 所屬分類: Clojure


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    導航

    統計

    常用鏈接

    留言簿(12)

    隨筆分類(54)

    隨筆檔案(59)

    文章分類(2)

    文章檔案(1)

    相冊

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 日韩精品福利片午夜免费观着| 岛国岛国免费V片在线观看| 国产精品亚洲精品日韩已满| 激情婷婷成人亚洲综合| 午夜电影免费观看| 亚洲国产无线乱码在线观看| 毛片a级毛片免费观看免下载 | XXX2高清在线观看免费视频| 亚洲精品国产精品国自产观看| 黄网站色视频免费看无下截| 亚洲国产人成中文幕一级二级| 免费一级毛suv好看的国产网站| 一个人免费日韩不卡视频| 日韩精品成人亚洲专区| 一级毛片无遮挡免费全部| 国产性爱在线观看亚洲黄色一级片| 亚洲免费日韩无码系列| 国产精品久免费的黄网站| 激情吃奶吻胸免费视频xxxx| 亚洲熟女乱综合一区二区| 久久亚洲国产成人影院| 色播在线永久免费视频| 美女黄频视频大全免费的| 国产国拍精品亚洲AV片| 嫩草成人永久免费观看| 亚洲中文字幕人成乱码| 国产精品免费小视频| 成人片黄网站色大片免费观看cn| 亚洲国产高清在线| 一级一黄在线观看视频免费| 亚洲热线99精品视频| 日韩吃奶摸下AA片免费观看| 午夜亚洲乱码伦小说区69堂| 亚洲男人的天堂www| 国产片AV片永久免费观看| 337p日本欧洲亚洲大胆人人| 亚洲精品夜夜夜妓女网| 免费av欧美国产在钱| 51午夜精品免费视频| 亚洲美女一区二区三区| 免费一区二区视频|