本文介紹了如何在 Oracle 中通過 XPath 獲取第一個(gè)元素的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
限時(shí)送ChatGPT賬號(hào)..
在我的 Oracle 數(shù)據(jù)庫中,我有這樣的記錄:
In my Oracle db I have records like this one:
<ROOT>
<Event>
<Type>sldkfvjhkljh</Type>
<ID>591252</ID>
</Event>
<Data>
<File>
<Name>1418688.pdf</Name>
<URL>/591252/1418688.pdf</URL>
</File>
<File>
<Name>1418688.xml</Name>
<URL>/591252/1418688.xml</URL>
</File>
</Data>
</ROOT>
我需要從第一個(gè)
標(biāo)簽中提取一個(gè)值.如果我嘗試:
I need to extract a value from the first <Name>
tag. If I try:
Select xmltype(xml_data).extract('//Name[1]/text()').getStringVal() from MY_TABLE
我明白了:
1418688.pdf1418688.xml
1418688.pdf1418688.xml
為什么會(huì)這樣,我怎樣才能得到 1418688.pdf
?
Why is that and how can I get just 1418688.pdf
?
甲骨文版本:
Oracle 數(shù)據(jù)庫 10g 企業(yè)版版本 10.2.0.4.0 - 64bi
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
推薦答案
我認(rèn)為這兩個(gè) Name 元素在本文檔中都是 #1,因?yàn)樵谒鼈兊墓?jié)點(diǎn)中,它們都是第一個(gè).試試 //File[1]/Name/text()
I think that both Name elements are #1 in this doc, because in their nodes they are each first. Try //File[1]/Name/text()
這篇關(guān)于如何在 Oracle 中通過 XPath 獲取第一個(gè)元素的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!