
That stuffed me up for a bit. I wrote some ugly template haskell a while back to automatically generate XmlPickler instances. can send to you if you want On Dec 23, 2009, at 7:55 AM, Tony Morris wrote:
Adding (a_remove_whitespace,v_1) as a parser option when running solves it. Silly me.
Tony Morris wrote:
I am trying to parse XML using HXT following http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XM...
Here is my XML file (way.xml):
<way id="27776903" visible="true" timestamp="2009-05-31T13:39:15Z" version="3" changeset="1368552" user="Matt" uid="70"> <tag k="access" v="private"/> <tag k="highway" v="service"/> </way>
The problem is when parsing, by reading the <tag> entries into the list held by the Way data structure, I cannot get anything but an empty list.
Here is my parsing code:
import Text.XML.HXT.Arrow
newtype Way = Way { tags :: [Tag] } deriving (Eq, Show)
xpWay :: PU Way xpWay = xpElem "way" (xpWrap (Way, tags) (xpList xpTag))
data Tag = Tag { k :: String, v :: String } deriving (Eq, Show)
xpTag :: PU Tag xpTag = xpElem "tag" (xpWrap (uncurry Tag, k &&& v) (xpPair (xpAttr "k" xpText) (xpAttr "v" xpText)))
When I run, I get the following result:
Main> run = runX (xunpickleDocument xpWay [] "way.xml") [Way {tags = []}]
Why is the tags list empty instead of holding two entries?
-- Tony Morris http://tmorris.net/
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe