[Haskell-cafe] HXT: Replace an element with its text

Michael Orlitzky michael at orlitzky.com
Tue Jun 26 18:48:52 CEST 2012

On 06/26/12 10:39, Uwe Schmidt wrote:
> processTopDown $ (deep getText >>> mkText) `when` is_link
> should do it. The "deep getText" will find all Text nodes, independent
> of the nesting of elements in the <a>...</a> element. If you then
> write the result into a document every thing is fine.
> One small problem can occur when the content of the <a> Element
> has e.g. the form
> <body><a href="#">foo<b>bar</b></a></body>
> The resulting DOM then still contains two text nodes, one for "foo"
> and one for "bar". If you later search for a text "foobar"
> you don't find a node. The melting of adjacent text nodes can
> be done with
> ... (xshow (deep getText) >>> mkText) ...

Thanks for elaborating. This is just for display purposes, so hopefully
it won't be ever a problem. I'm parsing somebody else's HTML, though, so
who knows. I'll make a note in a comment.

Thanks again.

More information about the Haskell-Cafe mailing list