-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | XML subset DOM parser
--   
--   An XML DOM-style parser, that only parses a subset of XML, but is
--   designed to be fast.
@package hexml
@version 0.3.5

-- | A module for fast first-approximation parsing of XML. Note that
--   entities, e.g. &amp;, are not expanded.
module Text.XML.Hexml

-- | A node in an XML document, created by parse, then calling
--   functions such as children on that initial Node.
data Node

-- | An XML attribute, comprising of a name and a value. As an example,
--   hello="world" would produce Attribute "hello"
--   "world".
data Attribute
Attribute :: ByteString -> ByteString -> Attribute
[attributeName] :: Attribute -> ByteString
[attributeValue] :: Attribute -> ByteString

-- | Parse a ByteString as an XML document, returning a Left error
--   message, or a Right document. Note that the returned node will
--   have a name of "", no attributes, and
--   contents as per the document. Often the first child will be the
--   <?xml ... ?> element. For documents which comprise an
--   XML node and a single root element, use children n !!
--   1.
parse :: ByteString -> Either ByteString Node

-- | Given a node, rerender it to something with an equivalent parse tree.
--   Mostly useful for debugging - if you want the real source document use
--   outer instead.
render :: Node -> ByteString

-- | Find the starting location of a node, the < character. The
--   first character will be reported as (line 1,column 1),
--   because thats how error messages typically do it.
location :: Node -> (Int, Int)

-- | Get the name of a node, e.g. <test /> produces
--   "test".
name :: Node -> ByteString

-- | Get the inner text, from inside the tag, e.g. <test />
--   produces "" and <test>hello</test>
--   produces "hello". The result will have identical
--   layout/spacing to the source document.
inner :: Node -> ByteString

-- | Get the outer text, including the tag itself, e.g. <test
--   /> produces "<test />" and
--   <test>hello</test> produces
--   "<test>hello</test>". The result will have
--   identical layout/spacing to the source document.
outer :: Node -> ByteString

-- | Get the attributes of this node.
attributes :: Node -> [Attribute]

-- | Get the direct child nodes of this node.
children :: Node -> [Node]

-- | Get the contents of a node, including both the content strings (as
--   Left, never blank) and the direct child nodes (as
--   Right). If you only want the child nodes, use children.
contents :: Node -> [Either ByteString Node]

-- | Get the first attribute of this node which has a specific name, if
--   there is one. A more efficient version of:
--   
--   
--   attributeBy n s = listToMaybe $ filter (\(Attribute a _) -> a == s $ attributes n
--   
attributeBy :: Node -> ByteString -> Maybe Attribute

-- | Get the direct children of this node which have a specific name. A
--   more efficient version of:
--   
--   
--   childrenBy p s = filter (\n -> name n == s) $ children p
--   
childrenBy :: Node -> ByteString -> [Node]
instance GHC.Show.Show Text.XML.Hexml.Str
instance GHC.Classes.Ord Text.XML.Hexml.Attribute
instance GHC.Classes.Eq Text.XML.Hexml.Attribute
instance GHC.Show.Show Text.XML.Hexml.Attribute
instance GHC.Show.Show Text.XML.Hexml.Node
instance Foreign.Storable.Storable Text.XML.Hexml.Str
