I'm having some problems with HXT, though I suspect it's just something I'm missing about arrows.
I have an XML structure like
<str name="field1">value</str>
<lst name="field2"><str>value2</str><str>value3</str></lst>
And internal structure like
data XmlData = XmlStr String | XmlList XmlData
Is there a way to collect elements at a step in an arrow?
getXmlData :: IOSArrow XmlTree (String, XmlData)
getXmlData = (getAttrl >>> getChildren >>> getText) &&&
((filterByType "str" >>> getText >>> arr (\x -> XmlStr x))
<+> (filterByType "lst" >>> getXmlData))
where filterByType t = isElem >>> hasName t >>> getChildren
The recursive call to getXmlData needs to collect it's answer and wrap in an XmlList constructor, but I don't know how to collect terms. Currently I'm accomplishing this with some post processing on the output (collecting on the same name), but I would like a better solution.