xml-lens: Lenses, traversals, and prisms for xml-conduit

[ bsd3, library, xml ] [ Propose Tags ]

This package provides DOM selectors based on lenses and prisms. See README.md for examples

[Skip to Readme]
Versions [RSS] [faq] 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6,,,, 0.2, 0.3
Change log CHANGELOG.md
Dependencies base (==4.*), case-insensitive, containers (>=0.4.0 && <0.7), lens (>=4.0 && <5.1), text (>=0.7 && <2), xml-conduit (>=1.1 && <1.10) [details]
License BSD-3-Clause
Copyright Copyright (C) 2021 Fumiaki Kinoshita
Author Fumiaki Kinoshita
Maintainer Fumiaki Kinoshita <fumiexcel@gmail.com>
Revised Revision 1 made by FumiakiKinoshita at 2021-02-19T14:56:32Z
Category XML
Home page https://github.com/fumieval/xml-lens
Bug tracker https://github.com/fumieval/xml-lens/issues
Source repo head: git clone https://github.com/fumieval/xml-lens.git
Uploaded by FumiakiKinoshita at 2021-01-06T11:48:25Z
Distributions LTSHaskell:0.3, NixOS:0.3
Downloads 9316 total (37 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-01-06 [all 1 reports]


[Index] [Quick Jump]


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

For package maintainers and hackage trustees


Readme for xml-lens-0.3

[back to package description]


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