如何从表中的XML字符串中提取详细信息 [英] How to extract details from XML string in table

查看:92
本文介绍了如何从表中的XML字符串中提取详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。


我有一个表(在Oracle中),其列定义为CLOB并且包含一串XML数据。


我要做的是取这个字符串并搜索< OLD>和< NEW>字符串中的标签如下:


< CHG client =" c; GK" id =" c; 12345">< COL NAM =" this_col_one" TYP = QUOT; C">< OLD>旧值与LT; / OLD>< NEW>新建-值LT; / NEW>">< OLD>旧值与LT; / OLD>< NEW>新建-value< / NEW>< / COL> ...

有人可以建议如何分解这个XML字符串,以便我可以提取OLD和NEW值以及然后将这些输入到另一个表格中?


我开始阅读有关XPATH的内容,但希望有人可以放松学习并提供一些示例。


谢谢你的帮助。


M:o)

Hi there.

I have a table (in Oracle) with a column defined as a CLOB and which holds a string of XML data.

What I am looking to do is to take this string and search for the <OLD> and <NEW> tags in a string such as the following:

<CHG client="c;GK" id="c;12345"><COL NAM="this_col_one" TYP="c"><OLD>old-value</OLD><NEW>new-value</NEW>"><OLD>old-value</OLD><NEW>new-value</NEW></COL>...

Could somebody advise on how to break down this XML string please, so that I can extract the OLD and NEW values and then input these into another table?

I am starting to read about XPATH but hopefully somebody can ease the learning and offer some examples.

Thank you for your help.

M :o)

推荐答案

基本上你可以访问< OLD> (< NEW>)标记带有// OLD(// NEW)XPath表达式,它为您提供了一个列表。尽管如此,实际的实现取决于你想对数据做什么(即如何)。
basicly you access the <OLD> (<NEW>) tags with the //OLD (//NEW) XPath expression, which give you a list. nevertheless, the actual implementation depends on what (i.e. how) you want to do with the data.


你好。


我想采取长xml字符串并将其分解为旧值和新值的各个部分,将其中的每一个放入另一个包含旧列和新列的表中 - 希望有意义..?


这是一个修正日志报告,它将引用我想要存储这些旧值和新值的表,以及其他详细信息,例如user_id和date,以对应于何时以及何时对表中的表进行更改系统。


谢谢。


M:)
Hi there.

I want to take the long xml string and break this down into the individual parts for old and new values, placing each of these into another table that has columns for old and new - hope that makes sense..?

This is for an amendment logging report which will reference the table I want to store these old and new values in, along with other details such as user_id and date, to correspond with who and when a change was made to a table elsewhere in the system.

Thank you.

M :)


我想我想要的是一个select语句,它也将获取相应的< OLD>和< NEW>来自名为XML_DATA的列的值,所以类似于

从aTable中选择// OLD,其中某些东西=另一个使用正确语法的语句。


M:)
I guess what I want is a select statement that will also grab the respective <OLD> and <NEW> value from a column called XML_DATA, so something like

select //OLD from aTable where something = anotherThing though ofcourse using the correct syntax.

M :)


这篇关于如何从表中的XML字符串中提取详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆