Safe Haskell | None |
---|---|
Language | Haskell2010 |
All documentation examples assume the following setup:
:set -XOverloadedStrings import Data.Attoparsec.ByteString import Data.XML.Parser.High
Synopsis
- newtype AttrParser a = AttrParser {}
- anyAttr :: AttrParser ()
- noAttr :: AttrParser ()
- attrValue :: QName -> AttrParser Text
- hasAttr :: QName -> Text -> AttrParser ()
Documentation
newtype AttrParser a Source #
How to parse tag attributes.
Instances
anyAttr :: AttrParser () Source #
Parse any set of attributes.
>>>
parseOnly (runTokenParser $ tag' anyName anyAttr noContent) "<tag></tag>"
Right ()>>>
parseOnly (runTokenParser $ tag' anyName anyAttr noContent) "<tag key='value'></tag>"
Right ()
noAttr :: AttrParser () Source #
Assert that no attributes exist.
>>>
parseOnly (runTokenParser $ tag' anyName noAttr noContent) "<tag></tag>"
Right ()>>>
parseOnly (runTokenParser $ tag' anyName noAttr noContent) "<tag key='value'></tag>"
Left ...
attrValue :: QName -> AttrParser Text Source #
Parse attribute by name, and return its value.
>>>
parseOnly (runTokenParser $ tag' anyName (attrValue "foo") noContent) "<tag></tag>"
Left ...>>>
parseOnly (runTokenParser $ tag' anyName (attrValue "foo") noContent) "<tag foo='bar'></tag>"
Right ()
hasAttr :: QName -> Text -> AttrParser () Source #
Assert that an attribute exists, with given name and value.
>>>
parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag></tag>"
Left ...>>>
parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag foo='baz'></tag>"
Left ...>>>
parseOnly (runTokenParser $ tag' anyName (hasAttr "foo" "bar") noContent) "<tag foo='bar'></tag>"
Right ()