更新时间:2023-11-15 12:57:16
You can use the EXTRACTVALUE
function to obtain this value. This function takes two or three parameters:
在下面的查询中,我将上面显示的XML作为字符串,并从中创建了XMLTYPE对象.然后,我使用EXTRACTVALUE
来获取您要求的值:
In the query below, I've taken the XML you presented above as a string and have created an XMLTYPE object from it. I then use EXTRACTVALUE
to get the value you asked for:
SELECT EXTRACTVALUE(XMLTYPE(
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<SOAProxyResponse xmlns="http://tempuri.org/">
<SOAProxyResult>
There is 23142 Files!
</SOAProxyResult>
</SOAProxyResponse>
</s:Body>
</s:Envelope>'), '//SOAProxyResult', 'xmlns="http://tempuri.org/"') AS result
FROM dual;
XPath表达式//SOAProxyResult
仅返回文档中的所有SOAProxyResult
元素. EXTRACTVALUE
的第三个参数将默认名称空间绑定到http://tempuri.org/
.这是必需的,因为XML文档中的SOAProxyResult
元素位于此命名空间之内.
The XPath expression //SOAProxyResult
merely returns all SOAProxyResult
elements in the document. The third argument to EXTRACTVALUE
binds the default namespace to http://tempuri.org/
. This is necessary because the SOAProxyResult
element in your XML document is within this namespace.
如果运行此查询,则会得到以下输出:
If I run this query, I get the following output:
RESULT
--------------------------------------------------------------------------------
There is 23142 Files!
从这里开始,希望可以对查询的结果进行简单的修改,以使其成为变量.
From here, it should hopefully be a trivial modification to put the result of this query into a variable.