Using Text.XML.Cursor
, is there a convenient way of selecting nodes matching one of several conditions (like an or
function)?
How can I get the cursors of all <p class="myclass">
and <h1>
nodes (in the right order) in the following example?
<div>
<p></p>
<div></div>
<h1></h1>
<hr>
<p class="myclass"></p>
<h1></h1>
</div>
extract :: Cursor -> [Cursor]
-- Returns 3 cursors [h1, p, h1]
There's
checkElement
which accepts a predicate.So with that, and knowing that your
extract
is anAxis
1:Adding the class check should be easy then; match the 2nd element from
Element
constructor, look for theclass
attribute, then inspect its value formyclass
presence.1
type Axis = Cursor -> [Cursor]