summaryrefslogtreecommitdiffstats
path: root/ocaml/examples/xmllight_loader.ml
blob: 46dd77f77aa98a11f6b8432c3e2e1608e5e54151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)