How to parse xml by xmltable when using namespace in xml(Oracle) -


i want parse xml string web service response sent servier, xml looks this:

<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">     <soap:body>         <addresponse xmlns="http://tempuri.org/">             <addresult>20</addresult>         </addresponse>     </soap:body> </soap:envelope> 

i want value 20 between elements addresult. plsql code segment looks following:

declare   v_xml clob; begin   v_xml := '<?xml version="1.0" encoding="utf-8"?>   <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">     <soap:body>       <addresponse xmlns="http://tempuri.org/">         <addresult>20</addresult>       </addresponse>     </soap:body>   </soap:envelope>';   c in (select results          xmltable('envelope/body/addresponse' passing xmltype(v_xml)          columns results varchar(100) path './addresult')        )   loop     dbms_output.put_line('the result of calculation : ' || c.results);   end loop; end; 

seems nothing printed out, if remove namespace 'soap', code works well, can tell me how can got value 20 when xml has namespace?

based on this answer

should this:

declare       v_xml clob;     begin       v_xml := '<?xml version="1.0" encoding="utf-8"?>       <soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema">         <soap:body>           <addresponse xmlns="http://tempuri.org/">             <addresult>20</addresult>           </addresponse>         </soap:body>       </soap:envelope>';       c in (select results                   xmltable(xmlnamespaces(default 'http://tempuri.org/',                                               'http://schemas.xmlsoap.org/soap/envelope/'                                               "soap" ),                                 'soap:envelope/soap:body/addresponse' passing                                 xmltype(v_xml) columns results varchar(100) path                                 './addresult')) loop         dbms_output.put_line('the result of calculation : ' || c.results);       end loop;     end; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -