输出 +----------------------------+--------------------+| EXCEPTIONTYPE | ROOTCAUSE |+----------------------------+--------------------+| VertexApplicationException | User login failed. |+----------------------------+--------------------+How can I extract the value from the label VertexApplicationException and User login failed. from below xml result?Inside my package, i am using 'make request api' call to get tax value calculated from vertex, sometimes i am getting error as response for my api call, now i need to store the response in table but only i need the error message ex: VertexApplicationException and User login failed. from the belowgiven xml response tag<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <nsf:Fault xmlns:nsf="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>nsf:Client</faultcode> <faultstring>User login failed.</faultstring> <detail> <ns:VertexException xmlns:ns="urn:vertexinc:oseries:exception:1:0"> <ns:exceptionType>VertexApplicationException</ns:exceptionType> <ns:rootCause>User login failed.</ns:rootCause> </ns:VertexException> </detail>`enter code here` </nsf:Fault> </S:Body></S:Envelope> 解决方案 You can try below query:select a.* from XMLTABLE ( xmlnamespaces( 'http://schemas.xmlsoap.org/soap/envelope/' as "S", 'http://schemas.xmlsoap.org/soap/envelope/' as "nsf", 'urn:vertexinc:oseries:exception:1:0' as "ns"), ' /S:Envelope/S:Body/nsf:Fault/detail/ns:VertexException ' PASSING XMLTYPE( ' <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <nsf:Fault xmlns:nsf="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>nsf:Client</faultcode> <faultstring>User login failed.</faultstring> <detail> <ns:VertexException xmlns:ns="urn:vertexinc:oseries:exception:1:0"> <ns:exceptionType>VertexApplicationException</ns:exceptionType> <ns:rootCause>User login failed.</ns:rootCause> </ns:VertexException> </detail>`enter code here` </nsf:Fault> </S:Body></S:Envelope> ') columns ExceptionType varchar2(40) path 'ns:exceptionType' , RootCause varchar2(40) path 'ns:rootCause') AS A;Check DEMO HereOutput+----------------------------+--------------------+| EXCEPTIONTYPE | ROOTCAUSE |+----------------------------+--------------------+| VertexApplicationException | User login failed. |+----------------------------+--------------------+ 这篇关于如何从xml结果中仅提取错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 15:11