[Haskell-beginners] Help in reading XML into a data type with HXT
Alexis Praga
alexispraga at mailoo.org
Sat Jan 24 17:29:13 UTC 2015
Hi,
I am trying to read a very simple xml node containing a list of other xml nodes into a data structure. Running the code yields :
fatal error: document unpickling failed
xpCheckEmptyContents: unprocessed XML content detected
context: element "animelist"
contents:
<title>Bleach</title>
<title>Naruto</title>
Can you help me debug this ? The code and xml are below :
8<---Code---------------------------------------------------------------------
module Main where
import System.Environment
import Text.XML.HXT.Core
type Anime = String
type AnimeList = [Anime]
xpAnime :: PU Anime
xpAnime
= xpElem "title" $ xpText
xpAnimeList :: PU AnimeList
xpAnimeList
= xpElem "animelist" $ xpList $ xpAnime
main :: IO ()
main = do
[src] <- getArgs
a <- runX ( xunpickleDocument xpAnimeList [] src)
mapM_ putStrLn a
return ()
8<----------------------------------------------------------------------------
8<---XML---------------------------------------------------------------------
<animelist>
<title>Bleach</title>
<title>Naruto</title>
</animelist>
8<----------------------------------------------------------------------------
Thanks,
--
Alexis Praga, PhD Student (CERFACS)
GPG key : AD4A AF6D BB5C 042F 9422 1223 06E1 C1BF E287 65D0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20150124/eb29823e/attachment.sig>
More information about the Beginners
mailing list