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
checkElementwhich accepts a predicate.So with that, and knowing that your
extractis anAxis1:Adding the class check should be easy then; match the 2nd element from
Elementconstructor, look for theclassattribute, then inspect its value formyclasspresence.1
type Axis = Cursor -> [Cursor]