<div dir="ltr"><div><div><div><div><div><div>Use arrow notation and zeroArrow, like so:<br><br></div>{-# LANGUAGE Arrows #-}<br>import Text.XML.HXT.Core<br>getA =<br>  hasName &quot;a&quot; &gt;&gt;&gt; proc elem -&gt; do<br>

    text &lt;- getText &lt;&lt;&lt; getChildren -&lt; elem<br>    if text == &quot;Hello Two!&quot;<br>      then getAttrValue &quot;href&quot; -&lt; elem<br>      else zeroArrow -&lt; ()<br><br>&gt;&gt;&gt; runX $ readString  [] &quot;&lt;html&gt;&lt;a href=&#39;<a href="http://example.com/somelink.html">example.com/somelink.html</a>&#39;&gt;Hello One!&lt;/a&gt;&lt;a href=&#39;<a href="http://example.com/anotherlink.html">example.com/anotherlink.html</a>&#39;&gt;Hello Two!&lt;/a&gt;&lt;/html&gt;&quot; &gt;&gt;&gt; deep getA<br>

[&quot;<a href="http://example.com/anotherlink.html">example.com/anotherlink.html</a>&quot;]<br><br></div></div></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 31, 2012 at 3:36 PM, Mateusz Kowalczyk <span dir="ltr">&lt;<a href="mailto:fuuzetsu@fuuzetsu.co.uk" target="_blank">fuuzetsu@fuuzetsu.co.uk</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
I&#39;m not sure if this is the right place to ask this but here goes.<br>
<br>
I&#39;m currently working with HXT and I quite like it. There&#39;s one issue I<br>
can&#39;t solve (at least now without some dirty, dirty hacking) and I&#39;m<br>
sure it&#39;s fairly simple.<br>
<br>
Consider the following mark-up<br>
<br>
&lt;a href=&quot;<a href="http://example.com/somelink.html" target="_blank">example.com/somelink.<u></u>html</a>&quot;&gt;Hello One!&lt;/a&gt;<br>
&lt;a href=&quot;<a href="http://example.com/anotherlink.html" target="_blank">example.com/anotherlink.<u></u>html</a>&quot;&gt;Hello Two!&lt;/a&gt;<br>
<br>
Now, what I&#39;m trying to achieve is to get the href based on the text. I<br>
can test for what the text is by traversing &lt;a&gt;s, then using the<br>
getChildren &gt;&gt;&gt; getText arrow. What I can&#39;t figure out is how to check<br>
the text and then get the href as by the time I get to the text, I&#39;ll<br>
further down the tree!<br>
<br>
I imagine it would look something along the lines of<br>
 (getChildren &gt;&gt;&gt; getText &lt;?*&gt; &quot;Hello Two&quot;) `guards` getAttrValue<br>
&quot;href&quot;. &lt;?*&gt; is just a random operator I made up for illustration<br>
purposes that works as a predicate over arrows.<br>
<br>
Is this the right approach? Is there a built-in that already does what I want? It<br>
seems like a common task...<br>
<br>
Mateusz Kowalczyk<br>
<br>
______________________________<u></u>_________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/<u></u>mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>