alice
library
manual.

Alice Project

The XML structure


________ Synopsis ____________________________________________________

    signature XML
    structure XML : XML
  

The XML structure provides a simple XML parser. It is based on the libxml2 library (see the libxml2 web page for further details).


________ Import ______________________________________________________

    import structure XML from "x-alice:/lib/xml/XML"

________ Interface ___________________________________________________

signature XML =
    sig
	type xml_node

	exception XMLError of string

	datatype xml_node_type =
	    ATTRIBUTE_DECL
	  | ATTRIBUTE_NODE
	  | CDATA_SECTION_NODE
	  | COMMENT_NODE
	  | DOCB_DOCUMENT_NODE
	  | DOCUMENT_FRAG_NODE
	  | DOCUMENT_NODE
	  | DOCUMENT_TYPE_NODE
	  | DTD_NODE
	  | ELEMENT_DECL
	  | ELEMENT_NODE
	  | ENTITY_DECL
	  | ENTITY_NODE
	  | ENTITY_REF_NODE
	  | HTML_DOCUMENT_NODE
	  | NAMESPACE_DECL
	  | NOTATION_NODE
	  | PI_NODE
	  | TEXT_NODE
	  | XINCLUDE_END
	  | XINCLUDE_START

	val parse : string -> xml_node
	val parseString : string -> xml_node
	fun name : xml_node -> string
	fun children : xml_node -> xml_node list
	fun null : xml_node -> bool
	fun parent : xml_node -> xml_node
	fun properties : xml_node -> xml_node list
	fun getType : xml_node -> xml_node_type
	fun getProp : xml_node -> string -> string option
	fun getContent : xml_node -> bool -> string option
    end
  

________ Description _________________________________________________

parse fileName

Parses the file fileName into an xml document tree and returns the root node. If this is not successfull, for example because the file does not exist or is malformed, this operation raises the XMLError exception with a string describing the error.

parseString s

Parses the string s into an xml document tree and returns the root node. If this is not successfull, for example because the string is malformed, this operation raises the XMLError exception with a string describing the error.

name node

Returns the name, i.e. the XML tag, of a node.

children node

Returns the list of children of node.

null node

Tests whether node is null, i.e. an illegal node. A null node is e.g. returned if you ask for the root node's parent.

parent node

Returns the parent of node, or null for the root.

properties node

Returns the list of properties that node has. Each property is again an xml_node.

getType node

Returns the type of node.

getProp node prop

If node has property prop with value v, return SOME v, otherwise NONE.

getContent node

If node contains text content text, return SOME text, otherwise NONE.



last modified 2007/Mar/30 17:10