taggy-0.2.1: Efficient and simple HTML/XML parsing library

Copyright(c) 2014 Alp Mestanogullari Vikram Verma
LicenseBSD3
Maintaineralpmestan@gmail.com
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Text.Taggy.DOM

Description

This module will help you represent an HTML or XML document as a tree and let you traverse it in whatever way you like.

This is especially useful when used in conjunction with taggy-lens

Synopsis

Documentation

type AttrName = Text Source #

An attribute name is just a Text value

type AttrValue = Text Source #

An attribute value is just a Text value

data Element Source #

An Element here refers to a tag name, the attributes specified withing that tag, and all the children nodes of that element. An Element is basically anything but "raw" content.

Constructors

Element 

Fields

Instances

data Node Source #

A Node is either an Element or some raw text.

Instances

Eq Node Source # 

Methods

(==) :: Node -> Node -> Bool #

(/=) :: Node -> Node -> Bool #

Show Node Source # 

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

AsMarkup Node Source #

A Node is convertible to Markup

Methods

toMarkup :: Bool -> Node -> Markup Source #

nodeChildren :: Node -> [Node] Source #

Get the children of a node.

If called on some raw text, this function returns [].

parseDOM :: Bool -> Text -> [Node] Source #

Parse an HTML or XML document as a DOM tree.

The Bool argument lets you specify whether you want to convert HTML entities to their corresponding unicode characters, just like in Text.Taggy.Parser.

parseDOM convertEntities = domify . taggyWith cventities

domify :: [Tag] -> [Node] Source #

Transform a list of tags (produced with taggyWith) into a list of toplevel nodes. If the document you're working on is valid, there should only be one toplevel node, but let's not assume we're living in an ideal world.

untilClosed :: Text -> ([Node], [Tag]) -> ([Node], [Tag]) Source #