Silent parsing

    let rec silentParsing t = 
       XML match t with
       | <_ as ns :_ as tn atts> _* as content  -> 
            Xml.iter silentParsing content

       | CDATA as cdata ->
           ()

    let _ = 
    try 
       silentParsing (Xml.of_in_channel (open_in Sys.argv.(1)))
    with Xml.ParseException e ->
       output_string stderr e;
       output_string stderr "\n"

Naive XML pretty printer

     let rec prettyPrint out i t = 
       try XML match t with
       | <_ as ns :_ as tn atts> _* as content </> -> 
           let rn = 
      	       if not (Xml.isEmpty ns) 
               then XML{ns ":" tn}
               else XML{tn} in
           prettyPrint_string out (i^"<");
           Xml.output out rn;
           List.iter (fun ((ns,na),v) -> 
             prettyPrint_string out (" "^na^"='");
             Xml.output out v;
             prettyPrint_string out "'") (Xml.attributes atts);
           prettyPrint_string out ">";
           Xml.iter (prettyPrint out (""^i)) content;
           output_string out (i^"</");
           Xml.output out rn;
           output_string out ">"
     
       | CDATA as cdata ->
           Xml.output out cdata
     
       | (* empty *) ->
           ()
        with Xml.MatchingFailure ->
          prerr_string ">>> "; 
          Xml.output stderr t; prerr_string " <<< \n";
          raise Not_found
       
     let _ = 
       try 
         let xml = (Xml.of_in_channel (open_in Sys.argv.(1))) in
         flush stdout;
         prettyPrint stdout "" xml;
         output_string stdout "\n"
       with Xml.ParseException e ->
         output_string stdout e