diff --git a/Text/XML/Light/Lexer.hs b/Text/XML/Light/Lexer.hs
--- a/Text/XML/Light/Lexer.hs
+++ b/Text/XML/Light/Lexer.hs
@@ -45,6 +45,20 @@
   next s' = n' `seq` ((n,'\n'):linenumber n' s') where n' = n + 1
 
 
+-- | This type may be used to provide a custom scanning function
+-- for extracting characters.
+data Scanner s = Scanner (Maybe (Char,s)) (s -> Maybe (Char,s))
+
+-- | This type may be used to provide a custom scanning function
+-- for extracting characters.
+customScanner :: (s -> Maybe (Char,s)) -> s -> Scanner s
+customScanner next s = Scanner (next s) next
+
+instance XmlSource (Scanner s) where
+  uncons (Scanner this next) = do (c,s1) <- this
+                                  return (c, Scanner (next s1) next)
+
+
 -- Lexer -----------------------------------------------------------------------
 
 type LChar              = (Line,Char)
diff --git a/xml.cabal b/xml.cabal
--- a/xml.cabal
+++ b/xml.cabal
@@ -1,5 +1,5 @@
 Name:            xml
-Version:         1.3.12
+Version:         1.3.13
 Homepage:        http://code.galois.com
 Synopsis:        A simple XML library.
 Description:     A simple XML library.
