我们有一些GUI问题,它们将我们所有的xml实体转换为它们的字符格式并存储在我们的Oracle DB中。
最大的问题是"
被转换为“在引用的xml属性值中。
<?xml version=...>
<Fetch searchstr=""brown fox" child* !"big planes"" begin="yesterday" ...>
<otherele>...</otherele>
<some>...</some>
</Fetch>
我需要通过将其转换为:
来修复它<?xml version=...>
<Fetch searchstr=""brown fox" child* !"big planes"" begin="yesterday" ...>
<otherele>...</otherele>
<some>...</some>
</Fetch>
我写这个是为了解决这个问题而且效果很好。
set content = replace (content,
regexp_substr(content, '<Fetch searchstr=".+" begin='),
'<Fetch searchstr="' ||
replace(regexp_replace(content,
'<Fetch searchstr="(.+)" begin=|.',
'\1'),
'"', '"')
|| '" begin=')
如何使这更简单,更有效?
谢谢!
答案 0 :(得分:0)
获取以下子字符串:
“棕色狐狸”小孩*!“大飞机”
..并将引号替换为:&amp; quot ;
SET DECLARE OFF;
SELECT SUBSTR(str, 1, INSTR(str, '""', 1, 1))
|| REPLACE(SUBSTR(str, INSTR(str, '""', 1, 1) + 1, INSTR(str, '""', -1, 1) - INSTR(str, '""', 1, 1)), '"', '"')
|| SUBSTR(str, INSTR(str, '""', -1, 1) + 1)
AS col
FROM
(
SELECT '<?xml version=...><Fetch searchstr=""brown fox" child* !"big planes"" begin="yesterday" ...><otherele>...</otherele><some>...</some></Fetch>' AS str
FROM DUAL
);
结果:
<?xml version=...><Fetch searchstr=""brown fox" child* !"big planes"" begin="yesterday" ...><otherele>...</otherele><some>...</some></Fetch>