解析存储在Oracle Table上的XML字符串 [英] Parse XML string stored on Oracle Table
问题描述
我有一个XML字符串,类似于存储在数据库中的字符串:
I've a XML string like that stored on my DB:
<?xml version="1.0" encoding="utf-8"?>
<AddressMaintenance>
<Label Name="lblAddress11">Address Line 1</Label><TextBox Name="txtAddress11">Zuellig Korea</TextBox>
</AddressMaintenance>
您知道是否可以使用XMLQuery或SQL提取 Zuelling Korea 的值吗?我无法创建临时表,因为它是一个验证环境,因此我只能读取该值.我知道可以使用reg exp,但是,如果可能的话,我尝试使用XML.
do you know if there is a way to extract the value Zuelling Korea using XMLQuery or SQL? I can't create a temporary table because it's a validate environment so I can only read that value. I know is possible using reg exp, but, if possible I try to use XML.
谢谢,
安德里亚
thanks,
Andrea
推荐答案
如果将其存储在表的XMLTYPE中,则可以使用Oracle XML函数通过XPath提取它:
If this is stored in an XMLTYPE on a table you can use the Oracle XML functions to extract it using XPath:
SELECT
extractvalue(xmlcol, '/*/TextBox[@Name=''txtAddress11'']') txtaddress
FROM yourtable
使XPath适应您的需求.
Adapt the XPath to suit your needs.
请参见 ExtractValue文档或进行其他研究Oracle XML函数.
See ExtractValue documentation or research other Oracle XML functions.
我应该注意,不建议使用11g及更高版本的extractvalue,您应该使用 XMLQuery
I should probably note that 11g and later, extractvalue is deprecated and you should use XMLQuery
这篇关于解析存储在Oracle Table上的XML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!