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]

Modules

[Index] [Quick Jump]

Downloads

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

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.6.1, 0.1.6.2, 0.1.6.3, 0.2, 0.3, 0.3.1
Change log CHANGELOG.md
Dependencies base (>=4 && <5), case-insensitive, containers (>=0.4.0 && <0.7), lens (>=4.0 && <5.3), text (>=0.7 && <1.3 || >=2 && <2.1), 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 2 made by FumiakiKinoshita at 2023-01-26T01:44:44Z
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 2022-05-15T11:18:51Z
Distributions LTSHaskell:0.3.1, NixOS:0.3.1
Reverse Dependencies 8 direct, 1 indirect [details]
Downloads 10669 total (65 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-05-15 [all 1 reports]

Readme for xml-lens-0.3.1

[back to package description]

xml-lens

Lenses and traversals for xml-conduit.

Example

> 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"
7

> 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"?>
<books>
<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>
    <price>£45.00</price>
</book>
<book category="Textbooks">
    <title>Learn You a Haskell for Great Good!</title>
    <author year="2011">Miran Lipovaca</author>
    <pages>360 pages</pages>
</book>
<book category="Textbooks">
    <title>Programming in Haskell</title>
    <author year="2007">Graham Hutton</author>
    <pages>200 pages</pages>
</book>
…

Tips

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