xml-lens

Lenses, traversals, and prisms for xml-conduit

https://github.com/fumieval/xml-lens

Version on this page:0.3
LTS Haskell 18.23:0.3@rev:1
Stackage Nightly 2021-06-14:0.3@rev:1
Latest on Hackage:0.3@rev:1

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:46f392a61ec2c4987345e67c761a285db0d47d4367c9c095133ce2c4f03bc296,1064

Module documentation for 0.3

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

Changes

0.3 (2021/01)

  • Deprecated el
  • Removed ./ and entire