Skip to content

Instantly share code, notes, and snippets.

@jb55
Created July 14, 2014 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jb55/405274181033f4f184db to your computer and use it in GitHub Desktop.
Save jb55/405274181033f4f184db to your computer and use it in GitHub Desktop.
conduit xml lenses
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Control.Lens
import Data.Text (Text)
import Text.Xml.Lens
import Text.XML
import qualified Data.Text.Lazy.IO as T
import Data.Default (def)
names :: AsXmlDocument t => Traversal' t Text
names = xml...node "Tag"
.attributed (ix "name".only "CardName")
.node "enUS"
.text
main = do
cards <- T.readFile "/home/jb55/cards.xml"
let parsed = parseText def cards
mapM_ print $ parsed ^.. _Right . names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment