
Hi, I think this is just a stupid arrow question. Still I cannot find where my mistake is located. Suppose I have a simple xml document I want to process with HXT: <root> <elem> <sub /> <risub>text</risub> </elem> </root> After extracting <elem> I want to duplicate the children trees with the arrow operator (&&&) and process them to get each sub element, like I try in treMe2. Below the example code. While I can get each sub element with tryMe and tryMe1, tryMe2 will produce a []. Instead I want something like tryMe3. I think I'm missing something stupid but right now I just feel stupidly blind. Thanks for your help, Andrea import Text.XML.HXT.Arrow xml = "<root><elem><sub /><risub>text</risub></elem></root>" tryMe = runLA arrow [] where arrow = constA xml >>> xread >>> deep (hasName "elem") >>> getChildren >>> (hasName "risub" >>> getChildren >>> getText) tryMe1 = runLA arrow [] where arrow = constA xml >>> xread >>> deep (hasName "elem") >>> getChildren >>> (hasName "sub" >>> withDefault (getChildren >>> getText) "ciao") tryMe2 = runLA arrow [] where arrow = constA xml >>> xread >>> deep (hasName "elem") >>> getChildren >>> (hasName "sub" >>> withDefault (getChildren >>> getText) "ciao") &&& (hasName "risub" >>> getChildren >>> getText) tryMe3 = runLA arrow [] where arrow = constA xml >>> xread >>> constA "first" &&& constA "second" The output: *test> tryMe ["text"] *test> tryMe1 ["ciao"] *test> tryMe2 [] *test> tryMe3 [("first","second")] *test>

On Sat, Aug 11, 2007 at 11:50:19AM +0200, Andrea Rossato wrote:
Hi,
I think this is just a stupid arrow question. Still I cannot find where my mistake is located.
well, it was not an arrow problem but a HXT problem. This new version of tryMe2 does work as expected: tryMe2 = runLA arrow [] where arrow = constA xml >>> xread >>> listA ( deep (hasName "elem") >>> (deep (hasName "sub") >>> withDefault (getChildren >>> getText) "ciao") &&& (deep (hasName "risub") >>> getChildren >>> getText) ) Sorry for the noise. Andrea
participants (1)
-
Andrea Rossato