Lenses, traversals, and prisms for xml-conduit


Version on this page:0.3@rev:1
LTS Haskell 22.26:0.3.1@rev:3
Stackage Nightly 2023-12-26:0.3.1@rev:2
Latest on Hackage:0.3.1@rev:3

See all snapshots xml-lens appears in

BSD-3-Clause licensed by Fumiaki Kinoshita
Maintained by Fumiaki Kinoshita
This version can be pinned in stack with:xml-lens-0.3@sha256:3de829f7590c05cdd9e1956da42363b8e0a3a5eb7073cc44e34d533385474447,1113

Module documentation for 0.3


Lenses and traversals for xml-conduit.


> doc <- Text.XML.readFile def "examples/books.xml"

> doc ^.. root . named "books" ... named "book" . attributeIs "category" "Textbooks" ... named "title" . text
["Learn You a Haskell for Great Good!","Programming in Haskell","Real World Haskell"]

> lengthOf ?? doc $ root . named "books" ... named "book"

> doc ^? root . named "books" ... attributeIs "category" "Joke" ... named "title" . text
Just "Functional Ikamusume"

> doc & root . named "books" ... named "book" ... named "pages" . text <>~ " pages" & renderLBS def & BL.putStrLn
<?xml version="1.0" encoding="ISO-8859-1"?>
<book category="Language and library definition">
    <title>Haskell 98 language and libraries: the Revised Report</title>
    <author year="2003">Simon Peyton Jones</author>
    <pages>272 pages</pages>
<book category="Textbooks">
    <title>Learn You a Haskell for Great Good!</title>
    <author year="2011">Miran Lipovaca</author>
    <pages>360 pages</pages>
<book category="Textbooks">
    <title>Programming in Haskell</title>
    <author year="2007">Graham Hutton</author>
    <pages>200 pages</pages>


  • Use cosmos to traverse over all children
  • You can do or-composition of traversals with failing


0.3 (2021/01)

  • Deprecated el
  • Removed ./ and entire