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:7a345c50f169f2836b42b806e7f0671d2490e0b6a640039cb553613a538c93ff,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