xml-conduit-microlens-0.3.0.0: Lenses and traversals for xml-conduit based on microlens
Copyright(c) 2015-2023 Fumiaki Kinoshita 2023 Marco Zocca
LicenseBSD-style
Maintainerocramz
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.XML.Lens.Micro

Description

XML (and HTML) DOM selectors for `xml-conduit` based on microlens.

This library provides combinators for traversing and folding over XML trees. It could be useful for editing trees, adding attributes selectively (e.g. refactoring CSS, adding HTMX attributes etc.)

Some definitions are taken from 'xml-lens' but we import microlens to achieve a smaller dependency footprint.

Synopsis

Documentation

subtree Source #

Arguments

:: (Text -> Bool)

predicate on element name

-> (Text -> Text -> Bool)

predicate on attribute name, value

-> Getting r Element (Maybe Element) 

Extract a DOM subtree whose root element satisfies the given predicates

remapAttributes Source #

Arguments

:: (Name -> Map Name Text -> Maybe (Map Name Text))

element name, element attributes

-> Getting r Element Element 

Remap all attributes. Handy for editing HREF or SRC targets, adding HTMX attributes to certain elements only, etc.

If the callback returns Nothing, the element attributes are left unchanged

From 'xml-lens'

root :: Lens' Document Element Source #

The root element of the Document.

epilogue :: Lens' Document [Miscellaneous] Source #

Epilogue, i.e. the last elements, of the Document

named :: CI Text -> Traversal' Element Element Source #

Traverse elements which has the specified *local* name (case-insensitive).

attrs :: Lens' Element (Map Name Text) Source #

Node attributes

attributeSatisfies Source #

Arguments

:: Name

attribute name

-> (Text -> Bool)

predicate on the value of the attribute

-> Traversal' Element Element 

Traverse over only the elements such that the value of the given attribute satisfy a predicate

attributeIs Source #

Arguments

:: Name

attribute name

-> Text

value of the attribute

-> Traversal' Element Element 

Traverse over only the elements with a given attribute name and value