xml-lens

Lenses, traversals, and prisms for xml-conduit

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

Version on this page:0.3.1@rev:2
LTS Haskell 22.39: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.1@sha256:0e46146268c967bd5f1f6a1b97bba6b67dbf88b1794daa0197ccbc3f9ba58c58,1135

Module documentation for 0.3.1

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.1

  • Supported GHC 9

0.3 (2021/01)

  • Deprecated el
  • Removed ./ and entire