本文介紹了如何在 Oracle 中通過 XPath 獲取第一個元素的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
在我的 Oracle 數據庫中,我有這樣的記錄:
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>
我需要從第一個
標簽中提取一個值.如果我嘗試:
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
為什么會這樣,我怎樣才能得到 1418688.pdf
?
Why is that and how can I get just 1418688.pdf
?
甲骨文版本:
Oracle 數據庫 10g 企業版版本 10.2.0.4.0 - 64bi
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
推薦答案
我認為這兩個 Name 元素在本文檔中都是 #1,因為在它們的節點中,它們都是第一個.試試 //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()
這篇關于如何在 Oracle 中通過 XPath 獲取第一個元素的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!