I am having problems with the HXT , although I suspect that this is just something I miss about the arrows.
I have an XML structure like
<str name="field1">value</str>
<lst name="field2"><str>value2</str><str>value3</str></lst>
And the internal structure is kind of
data XmlData = XmlStr String | XmlList XmlData
Is there a way to collect elements in an arrow step?
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
A recursive call to getXmlData should collect the answers and complete the XmlList constructor, but I don't know how to collect the terms. I am currently doing this with some post processing on the output (collecting the same name), but I would like to get a better solution.
source
share