(* Wrapper around Perl HTML::Element class.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: pl_HTML_Element.ml,v 1.1 2003-10-12 17:33:15 rich Exp $
+ * $Id: pl_HTML_Element.ml,v 1.2 2003-10-14 16:05:22 rich Exp $
*)
open Perl
let svlist = call_method_array sv "content_list" [] in
List.map
(fun c ->
- match sv_type c with
- SVt_PV -> String (string_of_sv c)
- | SVt_RV -> Element (new html_element (deref c))
- | _ -> failwith "HTML::Element content_type: unknown type"
+ (* Not very satisfactory, but sv_type fails to discern the type
+ * for some reason. XXX
+ *)
+ let str = string_of_sv c in
+ let marker = "HTML::Element=HASH(" in
+ let marker_len = String.length marker in
+ if String.length str > marker_len &&
+ String.sub str 0 marker_len = marker then
+ Element (new html_element c)
+ else
+ String (string_of_sv c)
) svlist
method all_attr =
let svlist = call_method_array sv "all_attr" [] in