1 (** Wrapper around Perl [HTML::Form] class.
3 * Copyright (C) 2003 Merjis Ltd.
5 * $Id: pl_HTML_Form.ml,v 1.3 2005-01-14 19:04:48 rich Exp $
12 let _ = eval "use HTML::Form"
14 class html_form (sv : sv) =
20 let sv = call_method sv "attr" [sv_of_string name] in
21 (* sv_is_undef doesn't work properly XXX *)
22 if sv_is_undef sv then None else Some (string_of_sv sv)
23 method set_attr name value =
24 call_method_void sv "attr" [sv_of_string name; sv_of_string value]
26 (* The following isn't a real method. The return type of HTML::Form->inputs
27 * isn't documented, but I wanted a list of input names (as strings) anyway.
30 let inputs = call_method_array sv "inputs" [] in
31 let names = List.map (fun sv -> call_method sv "name" []) inputs in
32 List.map string_of_sv names
36 let parse_document html_document base_uri =
37 let svlist = call_class_method_array "HTML::Form" "parse"
38 [sv_of_string html_document; sv_of_string base_uri] in
39 List.map (new html_form) svlist
41 let parse_response (res : http_response) =
42 let svlist = call_class_method_array "HTML::Form" "parse" [res#sv] in
43 List.map (new html_form) svlist