Help in reading XML into a data type with HXT

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

On 01/24/2015 12:29 PM, Alexis Praga wrote:
<animelist> <title>Bleach</title> <title>Naruto</title> </animelist>
HXT is picky about whitespace, you have to tell it to ignore those leading spaces. Try, runX ( xunpickleDocument xpAnimeList [ withRemoveWS yes ] src) instead.

On Sat, Jan 24, 2015 at 01:19:02PM -0500, Michael Orlitzky wrote:
HXT is picky about whitespace, you have to tell it to ignore those leading spaces.
Try,
runX ( xunpickleDocument xpAnimeList [ withRemoveWS yes ] src)
instead.
Thanks, I was going in circles there ! -- Alexis Praga, PhD Student (CERFACS) GPG key : AD4A AF6D BB5C 042F 9422 1223 06E1 C1BF E287 65D0
participants (2)
-
Alexis Praga
-
Michael Orlitzky