简体   繁体   English

使用oracle xml命令从XML字符串中提取值

[英]Extract values from XML string using oracle xml commands

I want to extract the values of the attributes active_ind and call_status from the following string: 我想从以下字符串中提取属性active_indcall_status的值:

<INSURANCE_HISTORY active_ind="Y" call_status="A"/>

I have sorted this issue with substring and instr , but need to use XML commands to extract these values. 我已经用substringinstr对这个问题进行了排序,但是需要使用XML命令来提取这些值。

Xpath, xquery, i recommend you to read something about these technology. Xpath,xquery,我建议您阅读有关这些技术的内容。 @ is used to access attribute in xml elment @用于访问xml元素中的属性

select extract(xmltype('<INSURANCE_HISTORY active_ind="Y" call_status="A"/>'),'/INSURANCE_HISTORY/@active_ind')  active_ind
, extract(xmltype('<INSURANCE_HISTORY active_ind="Y" call_status="A"/>'),'/INSURANCE_HISTORY/@call_status') call_status

 from dual;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM