Module Data/XML

This module is undocumented. This is a list of its definitions.

addCDATA :: Element -> String -> <Proc> ()

Appends the string to the content of the element as a CDATA section, so that it is written out without escaping.

addChild :: Element -> Element -> <Proc> ()

Appends the second element to the content of the first as its last child. Fails if the child already has a parent; detach it or use a fresh element instead.

addNamedChild :: Element -> String -> Element -> <Proc> ()

Renames the third argument to the given name and appends it to the first as its last child. If the child cannot be added, because it already has a parent, an error is printed and the child is left where it was.

attributeOf :: Element -> String -> <Proc> Maybe String

The value of the named attribute of the element, or Nothing if the element has no such attribute.

attributesOf :: Element -> <Proc> [Attribute]

All attributes of the element.

childWithNameOf :: Element -> String -> <Proc> Maybe Element

The first direct child with the given name, or Nothing if the element has no such child.

childrenOf :: Element -> <Proc> [Element]

All direct children of the element, in document order. Descendants deeper down are not included.

childrenWithNameOf :: Element -> String -> <Proc> [Element]

The direct children of the element that have the given name, in document order. Descendants deeper down are not included.

clearElementNamespace :: Element -> <Proc> ()

Removes the namespace from the element and from all of its descendants.

clearNamespace :: Document -> <Proc> ()

Removes the namespace from the root element of the document and from all of its descendants.

createDocument :: Element -> <Proc> Document

A document whose root element is the given element.

createElement :: String -> <Proc> Element

A new element with the given name, no attributes, no content and no parent.

elementsByXPath :: Element -> String -> <Proc> [Element]

The elements that the XPath expression selects, evaluated with the given element as the context node. Results that are not elements are left out. Fails if the expression is not valid XPath.

getCDATAs :: Element -> <Proc> [String]

The contents of the CDATA sections directly inside the element, in document order. Ordinary text of the element is not included.

nameOf :: Element -> <Proc> String

The name of the element, without any namespace prefix.

nameOfAttribute :: Attribute -> <Proc> String

The name of the attribute, without any namespace prefix.

outputString :: Document -> <Proc> String

Writes the document out as a string, indented and with line breaks between elements.

parentOf :: Element -> <Proc> Maybe Element

The element this element is a child of, or Nothing if it is a root element or has no parent yet.

parseFile :: String -> <Proc> Document

Parses the file with the given name as an XML document, building the whole document in memory. Fails if the file cannot be read or is not well formed XML.

parseFileWithSchemaFile :: String -> String -> <Proc> Document

Parses the file named by the second argument as an XML document and validates it against the XML Schema in the file named by the first. Fails if either file cannot be read or if the document does not conform to the schema.

parseString :: String -> <Proc> Document

Parses the string as an XML document. The whole document is built in memory, so this is not suitable for documents too large to hold there. Fails if the string is not well formed XML.

parseStringWithSchemaFile :: String -> String -> <Proc> Document

Parses the second argument as an XML document and validates it against the XML Schema in the file named by the first. Fails if the schema cannot be read or if the document does not conform to it.

rootElementOf :: Document -> <Proc> Element

The root element of the document. Fails if the document has no root element yet.

setAttribute :: Element -> String -> String -> <Proc> ()

Sets the attribute with the given name to the given value, adding it if the element did not have it.

setElementNamespace :: Element -> String -> <Proc> ()

Puts the element into the namespace with the given URI, and with it every descendant that is in no namespace yet. A descendant that already has a namespace keeps it, and so does everything below it.

setName :: Element -> String -> <Proc> ()

Renames the element.

setNamespace :: Document -> String -> <Proc> ()

Puts the document into the namespace with the given URI, as setElementNamespace does for its root element.

setRootElement :: Document -> Element -> <Proc> ()

Makes the element the root element of the document, replacing whatever root it had.

setText :: Element -> String -> <Proc> ()

Replaces the text content of the element with the given string, removing the content it had, child elements included.

sortChildrenBy :: Ord a => (Element -> <b> a) -> Element -> <Proc,b> ()

Sorts the direct children of the element by the key the function gives each of them. Only the children of the element are moved; their own children are left alone.

sortChildrenWith :: (Element -> Element -> <a> Integer) -> Element -> <Proc,a> ()

Sorts the direct children of the element with the given comparison function, which returns a negative number, zero or a positive number as its first argument is smaller than, equal to or greater than its second. Only the children of the element are moved; their own children are left alone.

textOf :: Element -> <Proc> String

The text directly inside the element, with the text of any child elements left out. The empty string if the element has no text of its own.

valueOfAttribute :: Attribute -> <Proc> String

The value of the attribute.