diff --git a/Text/XML/Expat/Format.hs b/Text/XML/Expat/Format.hs
--- a/Text/XML/Expat/Format.hs
+++ b/Text/XML/Expat/Format.hs
@@ -2,7 +2,7 @@
 -- Copyright (C) 2008 Evan Martin <martine@danga.com>
 -- Copyright (C) 2009 Stephen Blackheath <http://blacksapphire.com/antispam>
 
--- | This module provides lazy functions to format a tree
+-- | This module provides functions to format a tree
 -- structure as UTF-8 encoded XML.
 
 {-# LANGUAGE FlexibleContexts #-}
@@ -73,7 +73,7 @@
         putByteString $ gxToByteString aname
         putByteString $ pack "=\""
         putXMLText $ gxToByteString avalue
-        putByteString $ pack "\"" 
+        putByteString $ pack "\""
     if null children
         then
             putByteString $ pack "/>"
@@ -83,6 +83,7 @@
             putByteString $ pack "</"
             putThisTag
             putWord8 $ c2w '>'
+    flush
 putNode (Text txt) =
     putXMLText $ gxToByteString txt
 
diff --git a/Text/XML/Expat/Tree.hs b/Text/XML/Expat/Tree.hs
--- a/Text/XML/Expat/Tree.hs
+++ b/Text/XML/Expat/Tree.hs
@@ -91,6 +91,7 @@
   UNode,
   UNodes,
   UAttributes,
+  extractText,
   -- * Parse to tree
   parseTree,
   parseTree',
@@ -122,6 +123,7 @@
 import qualified Data.Text.Encoding as TE
 import qualified Codec.Binary.UTF8.String as U8
 import Data.Binary.Put
+import Data.Monoid
 import Data.Typeable
 import Control.Exception.Extensible as Exc
 import Control.Applicative
@@ -222,6 +224,12 @@
 -- text are the same string type.
 type UAttributes text = Attributes text text
 
+-- | Extract all text content from inside a tag into a single string, including
+-- any text contained in children.
+extractText :: Monoid text => Node tag text -> text
+extractText (Element _ _ children) = mconcat $ map extractText children
+extractText (Text txt) = txt
+
 modifyChildren :: ([Node tag text] -> [Node tag text])
                -> Node tag text
                -> Node tag text
@@ -288,7 +296,7 @@
 
 -- | Lazily parse XML to SAX events. In the event of an error, FailDocument is
 -- the last element of the output list.
-parseSAX :: (Show tag, Show text, GenericXMLString tag, GenericXMLString text) =>
+parseSAX :: (GenericXMLString tag, GenericXMLString text) =>
             Maybe Encoding      -- ^ Optional encoding override
          -> L.ByteString        -- ^ Input text (a lazy ByteString)
          -> [SAXEvent tag text]
@@ -337,7 +345,7 @@
 instance Exception XMLParseException where
 
 -- | Lazily parse XML to SAX events. In the event of an error, throw 'XMLParseException'.
-parseSAXThrowing :: (Show tag, Show text, GenericXMLString tag, GenericXMLString text) =>
+parseSAXThrowing :: (GenericXMLString tag, GenericXMLString text) =>
                     Maybe Encoding      -- ^ Optional encoding override
                  -> L.ByteString        -- ^ Input text (a lazy ByteString)
                  -> [SAXEvent tag text]
@@ -414,16 +422,15 @@
 -- | Lazily parse XML to tree. Note that forcing the XMLParseError return value
 -- will force the entire parse.  Therefore, to ensure lazy operation, don't
 -- check the error status until you have processed the tree.
-parseTree :: (Show tag, Show text, GenericXMLString tag, GenericXMLString text) =>
+parseTree :: (GenericXMLString tag, GenericXMLString text) =>
              Maybe Encoding      -- ^ Optional encoding override
           -> L.ByteString        -- ^ Input text (a lazy ByteString)
           -> (Node tag text, Maybe XMLParseError)
 parseTree mEnc bs = saxToTree $ parseSAX mEnc bs
 
 -- | Lazily parse XML to tree. In the event of an error, throw 'XMLParseException'.
-parseTreeThrowing :: (Show tag, Show text, GenericXMLString tag, GenericXMLString text) =>
+parseTreeThrowing :: (GenericXMLString tag, GenericXMLString text) =>
              Maybe Encoding      -- ^ Optional encoding override
           -> L.ByteString        -- ^ Input text (a lazy ByteString)
           -> Node tag text
 parseTreeThrowing mEnc bs = fst $ saxToTree $ parseSAXThrowing mEnc bs
-
diff --git a/hexpat.cabal b/hexpat.cabal
--- a/hexpat.cabal
+++ b/hexpat.cabal
@@ -1,6 +1,6 @@
 Cabal-Version: >= 1.2
 Name: hexpat
-Version: 0.7
+Version: 0.8
 Synopsis: wrapper for expat, the fast XML parser
 Description:
   Expat (<http://expat.sourceforge.net/>) is a stream-oriented XML parser
diff --git a/test/tests.hs b/test/tests.hs
--- a/test/tests.hs
+++ b/test/tests.hs
@@ -116,6 +116,14 @@
         ["start open","start test1","end test1","start hello","end hello","end open"]
         l
 
+test_extractText = do
+    let tree = Element "cheese" [("type", "edam")]
+            [Text "You don't actually ",
+             Element "sub" [] [Text "have any "],
+             Text "cheese at all",
+             Text ", do you?"]
+    assertEqual "extractText" "You don't actually have any cheese at all, do you?" (extractText tree)
+
 main = do
     testXML <- readFile "test.xml"
     -- Remove trailing newline
@@ -150,6 +158,7 @@
         TestCase $ test_error2,
         TestCase $ test_error3,
         TestCase $ test_error4,
-        TestCase $ test_parse
+        TestCase $ test_parse,
+        TestCase $ test_extractText
       ]
 
