Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XPath,在Oracle中解析XML和删除XML属性_Xml_Oracle_Xpath - Fatal编程技术网

XPath,在Oracle中解析XML和删除XML属性

XPath,在Oracle中解析XML和删除XML属性,xml,oracle,xpath,Xml,Oracle,Xpath,我正在尝试使用XPath从Oracle中的XML字段提取数据。 因此,基本上,当我试图使用XPath表达式-//SessionID从XML字段提取SessionID时,我得到null。 为了获得所需的输出,我必须执行类似于/*/*[1]/text的操作,这不是很好,因为如果结构发生变化,它将无法工作。 我已经意识到xmlns属性有一个问题,这就是它不能按预期工作的原因。 有人能帮我吗?关于如何删除xmlns属性,或以某种方式绕过它 下面是我用来得到正确答案的表达式 select EXTRACT(

我正在尝试使用XPath从Oracle中的XML字段提取数据。 因此,基本上,当我试图使用XPath表达式-//SessionID从XML字段提取SessionID时,我得到null。 为了获得所需的输出,我必须执行类似于/*/*[1]/text的操作,这不是很好,因为如果结构发生变化,它将无法工作。 我已经意识到xmlns属性有一个问题,这就是它不能按预期工作的原因。 有人能帮我吗?关于如何删除xmlns属性,或以某种方式绕过它

下面是我用来得到正确答案的表达式

select EXTRACT(XMLTYPE('<Session xmlns="http://www.tibco.com" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SessionID>ASDASDASD</SessionID></Session>'),'/*/*[1]/text()')
来自双重

我尝试过使用Deletexml,但它不适用于xmlns。它适用于其他属性,但不适用于xmlns,所以我想这不是解决方案


提前感谢您的帮助。

如果您想忽略名称空间,只需使用本地名称函数即可:

SELECT EXTRACT (
          XMLTYPE (
             '<Session xmlns="http://www.tibco.com" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
             xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SessionID>ASDASDASD</SessionID></Session>'),
          '//*[local-name() = "SessionID"]/text()') from dual