hexpat-0.12: wrapper for expat, the fast XML parserSource codeContentsIndex
Text.XML.Expat.NodeClass
Description
A typeclass to allow for functions that work with different node types such as the ones defined in Tree and Annotated.
Synopsis
class NodeClass n where
isElement :: n tag text -> Bool
isText :: n tag text -> Bool
textContent :: Monoid text => n tag text -> text
isNamed :: Eq tag => tag -> n tag text -> Bool
getName :: GenericXMLString tag => n tag text -> tag
getAttributes :: n tag text -> [(tag, text)]
getChildren :: n tag text -> [n tag text]
modifyName :: (tag -> tag) -> n tag text -> n tag text
modifyAttributes :: ([(tag, text)] -> [(tag, text)]) -> n tag text -> n tag text
modifyChildren :: ([n tag text] -> [n tag text]) -> n tag text -> n tag text
mapAllTags :: (tag -> tag') -> n tag text -> n tag' text
mapElement :: ((tag, [(tag, text)], [n tag text]) -> (tag', [(tag', text)], [n tag' text])) -> n tag text -> n tag' text
getAttribute :: (NodeClass n, GenericXMLString tag) => n tag text -> tag -> Maybe text
setAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> text -> n tag text -> n tag text
deleteAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> n tag text -> n tag text
alterAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> Maybe text -> n tag text -> n tag text
Documentation
class NodeClass n whereSource
Methods
isElement :: n tag text -> BoolSource
Is the given node an element?
isText :: n tag text -> BoolSource
Is the given node text?
textContent :: Monoid text => n tag text -> textSource
Extract all text content from inside a tag into a single string, including any text contained in children.
isNamed :: Eq tag => tag -> n tag text -> BoolSource
Is the given node a tag with the given name?
getName :: GenericXMLString tag => n tag text -> tagSource
Get the name of this node if it's an element, return empty string otherwise.
getAttributes :: n tag text -> [(tag, text)]Source
Get the attributes of a node if it's an element, return empty list otherwise.
getChildren :: n tag text -> [n tag text]Source
Get children of a node if it's an element, return empty list otherwise.
modifyName :: (tag -> tag) -> n tag text -> n tag textSource
Modify name if it's an element, no-op otherwise.
modifyAttributes :: ([(tag, text)] -> [(tag, text)]) -> n tag text -> n tag textSource
Modify attributes if it's an element, no-op otherwise.
modifyChildren :: ([n tag text] -> [n tag text]) -> n tag text -> n tag textSource
Modify children (non-recursively) if it's an element, no-op otherwise.
mapAllTags :: (tag -> tag') -> n tag text -> n tag' textSource
Map all tags (both tag names and attribute names) recursively.
mapElement :: ((tag, [(tag, text)], [n tag text]) -> (tag', [(tag', text)], [n tag' text])) -> n tag text -> n tag' textSource
Map an element non-recursively, allowing the tag type to be changed.
show/hide Instances
getAttribute :: (NodeClass n, GenericXMLString tag) => n tag text -> tag -> Maybe textSource
Get the value of the attribute having the specified name.
setAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> text -> n tag text -> n tag textSource
Set the value of the attribute with the specified name to the value, overwriting the first existing attribute with that name if present.
deleteAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> n tag text -> n tag textSource
Delete the first attribute matching the specified name.
alterAttribute :: (Eq tag, NodeClass n, GenericXMLString tag) => tag -> Maybe text -> n tag text -> n tag textSource
setAttribute if Just, deleteAttribute if Nothing.
Produced by Haddock version 2.6.1