import Text.XML.Expat.Pickle import Text.XML.Expat.Tree import qualified Data.ByteString.Lazy as L -- Person name, age and description data Person = Person String Int String xpPerson :: PU (UNodes String) Person xpPerson = -- How to wrap and unwrap a Person xpWrap (\((name, age), descr) -> Person name age descr, \(Person name age descr) -> ((name, age), descr)) $ xpElem "person" (xpPair (xpAttr "name" xpText0) (xpAttr "age" xpickle)) (xpContent xpText0) people = [ Person "Dave" 27 "A fat thin man with long short hair", Person "Jane" 21 "Lives in a white house with green windows"] main = do L.putStrLn $ pickleXML (xpRoot $ xpElemNodes "people" $ xpList xpPerson) people