[Haskell-cafe] Backtracking in HXT
Mateusz Kowalczyk
fuuzetsu at fuuzetsu.co.uk
Mon Dec 31 15:36:11 CET 2012
Hello,
I'm not sure if this is the right place to ask this but here goes.
I'm currently working with HXT and I quite like it. There's one issue I
can't solve (at least now without some dirty, dirty hacking) and I'm
sure it's fairly simple.
Consider the following mark-up
<a href="example.com/somelink.html">Hello One!</a>
<a href="example.com/anotherlink.html">Hello Two!</a>
Now, what I'm trying to achieve is to get the href based on the text. I
can test for what the text is by traversing <a>s, then using the
getChildren >>> getText arrow. What I can't figure out is how to check
the text and then get the href as by the time I get to the text, I'll
further down the tree!
I imagine it would look something along the lines of
(getChildren >>> getText <?*> "Hello Two") `guards` getAttrValue
"href". <?*> is just a random operator I made up for illustration
purposes that works as a predicate over arrows.
Is this the right approach? Is there a built-in that already does what I
want? It
seems like a common task...
Mateusz Kowalczyk
More information about the Haskell-Cafe
mailing list