以下是我尝试从以下内容获取某些值的XML示例:
<ows:Operation name="DescribeFeatureType">
<ows:Parameter name="outputFormat">
<ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>
</ows:Parameter>
</ows:Operation>
<ows:Operation name="GetFeature">
<ows:Parameter name="resultType">
<ows:Value>results</ows:Value>
<ows:Value>hits</ows:Value>
</ows:Parameter>
<ows:Parameter name="outputFormat">
<ows:Value>text/xml; subtype=gml/3.1.1</ows:Value>
<ows:Value>GML2</ows:Value>
<ows:Value>GML2-GZIP</ows:Value>
<ows:Value>SHAPE-ZIP</ows:Value>
<ows:Value>csv</ows:Value>
<ows:Value>gml3</ows:Value>
<ows:Value>gml32</ows:Value>
<ows:Value>json</ows:Value>
<ows:Value>text/xml; subtype=gml/2.1.2</ows:Value>
<ows:Value>text/xml; subtype=gml/3.2</ows:Value>
</ows:Parameter>
</ows:Operation>
我想使用Oracle 10GR2中的XMLTABLE访问“GetFeature”操作的“outputFormat”参数值。
我尝试了各种各样的东西,但他们要么没有给我任何结果,要么全部。这是一个返回所有值的示例。
select t.*
from xmltable(xmlnamespaces(default 'http://www.opengis.net/wfs'
,'http://www.opengis.net/gml' as "gml"
,'http://www.opengis.net/wfs' as "wfs"
,'http://www.opengis.net/ows' as "ows"
,'http://www.w3.org/1999/xlink' as "xlink"
,'http://www.w3.org/2001/XMLSchema-instance' as "xsi"
,'http://www.opengis.net/ogc' as "ogc")
,'for $d in //ows:Operation/ows:Parameter/ows:Value
where //ows:Operation/@name = "GetFeature"
and //ows:Parameter/@name="outputFormat"
return $d' passing p_xml columns value varchar2(100) path '/') as t
非常感谢任何帮助。
答案 0 :(得分:2)
找到答案:
select t.*
from xmltable(xmlnamespaces(default 'http://www.opengis.net/wfs'
,'http://www.opengis.net/gml' as "gml"
,'http://www.opengis.net/wfs' as "wfs"
,'http://www.opengis.net/ows' as "ows"
,'http://www.w3.org/1999/xlink' as "xlink"
,'http://www.w3.org/2001/XMLSchema-instance' as "xsi"
,'http://www.opengis.net/ogc' as "ogc")
,'for $d in //ows:Operation/ows:Parameter/ows:Value
where $d/../../@name = "GetFeature"
and $d/../@name="outputFormat"
return $d' passing p_xml columns value varchar2(100) path '/') as t;
使用.. xpath表达式访问父节点。