如何使用oracle extractvalue函数选择xml数据,当我确实有两种不同的路径来寻址信息时?Oracle extractvalue选择xml数据到不同路径
为一年,品牌,我可以使用恢复的信息:
extractvalue(xmltype(x.xml, 0), '//Vehicle/Year') as VEC_YEAR,
但地址我有错误消息:ORA31011故障解析XML和ORA19202和LPX00601:无效令牌://品牌/信息/数据/地址
SELECT
extractvalue(xmltype(x.xml, 0), '//Vehicle/Year') as VEC_YEAR,
extractvalue(xmltype(x.xml, 0), '//Vehicle/Brand') as VEC_BRAND,
CASE
WHEN extractvalue(xmltype(x.xml, 0), '//Brand/Info/Data/Address') IS NOT NULL THEN extractvalue(xmltype(x.xml, 0), '//Brand/Info/Data/Address')
WHEN extractvalue(xmltype(x.xml, 0), '//Brand/MainInfo/Info/Data/Address') IS NOT NULL THEN extractvalue(xmltype(x.xml, 0), '//Brand/MainInfo/Info/Data/Address')
END as Adress,
FROM xml_table x
这些都是XML我要查询:
<?xml version="1.0" encoding="utf-8"?>
<VehicleValidation xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Validation Id="Validation">
<Vehicle>
<Year>2017</Year>
<Brand>One car brand</Brand>
</Vehicle>
<Brand>
<Info>
<Data>
<Address>
One car brand Address
</Address>
<Data>
</Info>
</Brand>
</Validation>
</VehicleValidation>
<?xml version="1.0" encoding="utf-8"?>
<VehicleValidation xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Validation Id="Validation">
<Vehicle>
<Year>2017</Year>
<Brand>One car brand</Brand>
</Vehicle>
<Brand>
<MainInfo>
<Info>
<Data>
<Address>
One car brand Address
</Address>
<Data>
</Info>
</MainInfo>
</Brand>
</Validation>
</VehicleValidation>
**请**显示您引用的有效XML数据集。 – OldProgrammer
只需在问题中添加即可 –