diff options
Diffstat (limited to 'ocaml/examples/xmllight_loader.ml')
-rw-r--r-- | ocaml/examples/xmllight_loader.ml | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ocaml/examples/xmllight_loader.ml b/ocaml/examples/xmllight_loader.ml new file mode 100644 index 00000000..46dd77f7 --- /dev/null +++ b/ocaml/examples/xmllight_loader.ml @@ -0,0 +1,16 @@ +open Xml +open Ocamlduce.Load + + +let from_xml ?ns xml = + let l = make ?ns () in + let rec aux = function + | Element (tag, attrs, child) -> + start_elem l tag attrs; List.iter aux child; end_elem l () + | PCData s -> + text l s in + aux xml; + get l + +let from_file ?ns s = from_xml ?ns (parse_file s) +let from_string ?ns s = from_xml ?ns (parse_string s) |