File: readRoads.hs

package info (click to toggle)
haskell-hexpat 0.20.13-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 916 kB
  • sloc: ansic: 12,303; haskell: 3,457; xml: 1,109; makefile: 5; sh: 5
file content (20 lines) | stat: -rw-r--r-- 607 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{-# LANGUAGE OverloadedStrings #-}
import Text.XML.Expat.Tree
import Control.Monad
import Data.Text (Text)
import qualified Data.Text as T
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as L
import Data.Maybe


-- Reads the contents of ROADS.xml from stdin
main :: IO ()
main = do
    bs <- L.getContents
    let Element _ _ chs = parseThrowing defaultParseOptions bs :: UNode Text
    forM_ chs $ \ch -> do
        case ch of
            elt@(Element "shape" _ _) -> do
                putStrLn $ T.unpack $ fromMaybe "" $ getAttribute elt "FULL_NAME"
            _ -> return ()