2 * ----------------------------------------------------------------------
7 (* The type 'document' represents parsed HTML documents.
8 * Element (name, args, subnodes): is an element node for an element of
9 * type 'name' (i.e. written <name ...>...</name>) with arguments 'args'
10 * and subnodes 'subnodes' (the material within the element). The arguments
11 * are simply name/value pairs. Entity references (something like %xy;)
12 * occuring in the values are NOT resolved.
13 * Arguments without values (e.g. <select name="x" multiple>: here,
14 * "multiple" is such an argument) are represented as (name,name), i.e. the
15 * name is returned as value.
16 * As argument names are case-insensitive, the names are all lowercase.
17 * Data s: is a character data node. Again, entity references are contained
18 * as such and not as what they mean.
22 Element of (string * (string*string) list * document list)
27 val no_end_tag : string list ref;;
28 (* List of tags which are always empty. This variable is pre-configured,
29 * but you may want to change it.
30 * It is important to know which elements are always empty, because HTML
31 * allows it to omit the end tag for them. For example,
32 * <a><b>x</a> is parsed as
33 * Element("a",[],[ Element("b",[],[]); Data "x" ])
34 * if we know that "a" is an empty element, but it is wrongly parsed as
35 * Element("a",[],[ Element("b",[], [ Data "x"]) ])
36 * if "a" is actually empty but we do not know it.
37 * An example of such a tag is "br".
40 val special_tag : string list ref;;
41 (* List of tags with a special rule for recognizing the end.
42 * This variable is pre-configured, but you may want to change it.
43 * The special rule is that the metacharacters '<', '>' and so on lose
44 * their meaning within the element, and that only the corresponding
45 * end tag stops this kind of scanning. An example is the element
46 * "javascript". Inner elements are not recognized, and the element
47 * can only be ended by </javascript>. (Other elements are also ended
48 * if an embracing element ends, e.g. "j" in <k><j></k>!)
50 * Note that comments are not recognized within special elements;
51 * comments are returned as character material.
54 val parse_string : string -> document list
55 (* Parses the HTML document from a string and returns it *)
57 val parse_file : in_channel -> document list
58 (* Parses the HTML document from a file and returns it *)
61 (* ======================================================================
65 * Revision 1.1 2000/11/17 09:57:28 lpadovan
68 * Revision 1.1 2000/03/03 01:07:25 gerd