let get_image xmls =
try
match List.find (find_ele "image") xmls with
Element (_,atts,subs) ->
let f s =
match List.find (find_ele s) subs with
Element (_,_,[PCData s]) -> s
| _ -> raise Not_found
in
let f_opt s =
try
match List.find (find_ele s) subs with
Element (_,_,[PCData s]) -> Some (f s)
| _ -> None
with _ -> None
in
Some { image_url = f "url" ;
image_title = f "title" ;
image_link = f "link" ;
image_width = apply_opt int_of_string (f_opt "width") ;
image_height = apply_opt int_of_string (f_opt "height") ;
image_desc = f_opt "description" ;
}
| _ ->
None
with
_ ->
None