通过SQL EXTRACTVALUE对命名空间XML使用XPath失败?
我正在尝试使用EXTRACTVALUE解析XML响应中的FaultMessage。下面是我的SQL代码:通过SQL EXTRACTVALUE对命名空间XML使用XPath失败?,sql,xml,xpath,soap,Sql,Xml,Xpath,Soap,我正在尝试使用EXTRACTVALUE解析XML响应中的FaultMessage。下面是我的SQL代码: SELECT EXTRACTVALUE( XMLTYPE(' <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <s:Fault> <faultcode>s:Client</faultcode> &l
SELECT EXTRACTVALUE( XMLTYPE('
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode>s:Client</faultcode>
<faultstring xml:lang="tr-TR">İstek şeması doğrulanamadı. Lütfen tüm bilgileri kontrol edin.</faultstring>
<detail>
<Fault xmlns="http://schemas.datacontract.org/2004/07/CustomServiceLibrary.DataContract" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<FaultCode>Schema_Customer_005|1e8c66-c333-4357-9c7d-3f4fcd553</FaultCode>
<FaulCategory>Schema</FaulCategory>
<FaultMessage> Customer name can not be blank, can not contain spaces, or any special characters. LASTNAMEFIRSTNAME is the required format. </FaultMessage>
<FaultDetailedMessage>UMUT DEMIRCI</FaultDetailedMessage>
</Fault>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>'),
'/s:Envelope/s:Body/s:Fault/detail/*:Fault/FaultMessage',
'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.datacontract.org/2004/07/CustomServiceLibrary.DataContract" ') a
FROM DUAL
请建议如何获取FaultMessage。给定:
较深的断层单元及其后代位于http://schemas.datacontract.org/2004/07/CustomServiceLibrary.DataContract 命名空间。
您似乎已经为定义了名称空间前缀http://schemas.datacontract.org/2004/07/CustomServiceLibrary.DataContract
使用*作为命名空间前缀的通配符需要XPath 2.0+。
改变
到
这样您的XPath将是正确的,并且不需要XPath2.0+处理器
/s:Envelope/s:Body/s:Fault/detail/*:Fault/FaultMessage
/s:Envelope/s:Body/s:Fault/detail/a:Fault/a:FaultMessage