I am getting a response for a request(l_value) as below:
<?xml version="1.0" encoding="utf-8"?>
<boolean xmlns="
http://tempuri.org/" >false</boolean>
How do I get the boolean value false and assign it to a variable lv_return
httpresp := UTL_HTTP.GET_RESPONSE(httpreq);
BEGIN
LOOP
UTL_HTTP.READ_LINE(httpresp, l_value, TRUE);
DBMS_OUTPUT.PUT_LINE(l_value);
END LOOP;
UTL_HTTP.END_RESPONSE(httpresp);
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
--return Status
RETURN lv_return;
A bit of xmltype work will help out here
SQL> set serverout on
SQL> declare
2 v varchar2(1000) := '<?xml version="1.0" encoding="utf-8"?><boolean xmlns="http://tempuri.org/">false</boolean>';
3 x xmltype;
4 c varchar2(20);
5 begin
6 x := xmltype(v);
7 c := x.extract('boolean/text()','xmlns="http://tempuri.org/"').GETSTRINGVAL();
8 dbms_output.put_line(c);
9 end;
10 /
false
PL/SQL procedure successfully completed.
So now that it is a string, all the normal PL/SQL rules can be used, eg
return c = 'true' ;
or to be more definitive
return case when c = 'true' then true when c = 'false' then false end;