Created
July 14, 2014 08:32
-
-
Save jb55/405274181033f4f184db to your computer and use it in GitHub Desktop.
conduit xml lenses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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