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

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

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


[Skip to Readme]

Properties

Versions 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, 0.3.1
Change log CHANGELOG.md
Dependencies base (>=4 && <5), case-insensitive, containers (>=0.4.0 && <0.7), lens (>=4.0 && <5), 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>
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-06T09:42:01Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for xml-lens-0.3

[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