[Haskell-cafe] HaXml problem

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Mon Dec 4 07:29:12 EST 2006


Alexis Hazell <bonobo at bigpond.net.au> wrote:

> Say i have data of type Content, and i want to put that data into a
> type which  is an instance of XmlContent, so that i can use it with
> hPutXml. How can i do  so? Does it involve the List1 type and its
> NonEmpty constructor?

I don't fully understand the question.  Do you mean that you have data
of the HaXml-defined type Text.XML.HaXml.Types.Content?  If so, then
there is no need to convert it to any instance of XmlContent, just in
order to write it to a file.  hPutXml would only convert it back again!

You can write ordinary Content data just using

    import Text.XML.HaXml.Pretty as PP
    import Text.PrettyPrint.HughesPJ (render)

    main = ( hPutStrLn h . render . PP.content ) mydata

Regards,
    Malcolm


More information about the Haskell-Cafe mailing list