So i'm parsing this XML file . Once i reach a node inside it i have one child for a code , one for a descrition and one or more (grandchildren) nodes keeping outside node references.
I first tried simple arrow notation and <+> aggregation to get all the info i wanted but that just popped a big list and i thought perhaps there was a more elegant way to achieve this
So i tried arrow do notation instead and make the code look something along the lines:
import Text.XML.HXT.Core
getDocument cale = readDocument [withValidate no] cale
atName name=deep (hasName name)
text = getChildren>>>getText
getList = deep (hasName "list-info")>>>
proc x -> do
desc <- text <<< atName "desc" -< x
code <- text <<< atName "code" -< x
refs <- getAttrValue "idref" <<< deep (hasName "service-id-ref") -< x
returnA -< (desc,code,refs)
Basically deep is supposed to return all "service-id-ref" nodes on the same level as far as my understanding goes of this filter but the first node satisfying the "list-info" name has 2 "service-id-ref" child nodes on 2 different grand-grand children nodes and refs is bound only to the first one each time . So basically i was expecting a 3-tuple of (String,String,[String]) but all i got is 3 normal Strings.
Is it because of my poor understanding of arrows in do-notation (or in general) or should i try to bind refs some other way ?
Thanks in advance
I don't have your xml file so it's difficult to check if my answer is correct. But based on the expected result, you want a list of strings for the refs.
In Arrow to obtain list there's the function listA.
So your code may be changed into something like this (untested) :
refs <- listA (getAttrValue "idref" <<< deep (hasName "service-id-ref")) -< x
Have you read examples from : http://www.haskell.org/haskellwiki/HXT/Practical/Simple2 ?
Look at the code getTeams3 for inspiration.