File: Utils.hs

package info (click to toggle)
haskell-feed 1.3.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: haskell: 4,735; xml: 4,315; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 585 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Text.RSS.Utils where

import Prelude.Compat

import Data.Text
import Data.XML.Types as XML
import Text.XML as C

createContent :: Text -> XML.Node
createContent = XML.NodeContent . ContentText

createQName :: Text -> Name
createQName txt = XML.Name {nameLocalName = txt, nameNamespace = Nothing, namePrefix = Nothing}

type Attr = (Name, [Content])

mkNAttr :: Name -> Text -> Attr
mkNAttr k v = (k, [ContentText v])

elementToDoc :: XML.Element -> Maybe C.Document
elementToDoc el =
  either (const Nothing) Just $ fromXMLDocument $ XML.Document (Prologue [] Nothing []) el []