]> xenbits.xensource.com Git - xcp/xen-api-libs.git/commitdiff
[rpc-light] modify xml-light2 to expose few more accessors, in order to look much...
authorThomas Gazagnaire <thomas.gazagnaire@citrix.com>
Wed, 16 Sep 2009 14:37:14 +0000 (15:37 +0100)
committerThomas Gazagnaire <thomas.gazagnaire@citrix.com>
Wed, 16 Sep 2009 14:37:14 +0000 (15:37 +0100)
xml-light2/xml.ml
xml-light2/xml.mli

index a8d6059b099a18cbe33f5e1167f3fd99774475fc..af197dd1cb04dcbe13cbc30ffaa1507deb9f940e 100644 (file)
@@ -195,3 +195,19 @@ let to_bigbuffer xml =
        let buffer = Bigbuffer.make () in
        to_fct xml (fun s -> Bigbuffer.append_substring buffer s 0 (String.length s));
        buffer
+
+(* helpers functions *)
+exception Not_pcdata of string
+exception Not_element of string
+
+let pcdata = function
+       | PCData x -> x
+       | e -> raise (Not_pcdata (to_string e))
+
+let children = function
+       | Element (_,_,c) -> c
+       | e -> raise (Not_element (to_string e))
+
+let tag = function
+       | Element (x,_,_) -> x
+       | e -> raise (Not_element (to_string e))
index efc8f581ac7509a87a7fd07422aa5446db37e836..667158f83b8a5522dd80984e90268f0469ebb7e3 100644 (file)
@@ -22,3 +22,10 @@ val to_fct_fmt : xml -> (string -> unit) -> unit
 val to_string : xml -> string
 val to_string_fmt : xml -> string
 val to_bigbuffer : xml -> Bigbuffer.t
+
+(** helper functions *)
+exception Not_pcdata of string
+exception Not_element of string
+val pcdata : xml -> string
+val children : xml -> xml list
+val tag : xml -> string