current code:
let check_domain_existence doc host_name =
let xpathctx = Xml.xpath_new_context doc in
let xpath_string = xpath_string xpathctx in
let obj = Xml.xpath_eval_expression xpathctx
“/responses/response/output/vm” in
let nr_nodes = Xml.xpathobj_nr_nodes obj in
if nr_nodes > 0 then
j=0 in
for i = 0 to nr_nodes-1 do
let node = Xml.xpathobj_node obj i in
Xml.xpathctx_set_current_context xpathctx node;
let domain_name =
match xpath_string “name” with
| None -> “”
| Some sname -> (string_trim sname)
in
if domain_name = host_name then
error Vm_name_already_exists (f_"a domain with the same name %s has already exist in the system") domain_name;
done;
;;
since its throwing error Vm_name_already_exists i want to make it as host_name ^ string_of_int i+1
update host_name by concating with integer i and again check if the host name already exist, if exist it should again increment