尝试从CLOB XML列获取值时,出现以下错误:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00601: Invalid token in: '/l-analysis/vehicle/odometer-reading/reading value/text()'
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
我有以下XML输出:
<?xml version="1.0" encoding="UTF-8"?>
<l-analysis>
<vehicle>
<make>SAAB</make>
<model>9000 CSI</model>
<body-style code="SL">Saloon</body-style>
<vehicle-type code="7">Passenger car/van</vehicle-type>
<odometer-reading latest="true">
<reading value="154267213">154267213</reading>
<reading-date value="2006-07-17">17-Jul-2006</reading-date>
</odometer-reading>
</vehicle>
</l-analysis>
当尝试获取reading value
值时,我正在运行以下查询:
select XMLTYPE(xml_data).EXTRACT('/l-analysis/vehicle/odometer-reading/reading value/text()').getStringVal() AS XML FROM lm
我认为错误是由于reading value
包含空格? “造成另一个没有空格的XML列起作用的原因。
我该如何工作?
答案 0 :(得分:0)
value
是reading
的属性,而不是其文本。要寻址节点的属性,请使用@<attribute name>
。
SELECT xmltype(xml_data).extract('/l-analysis/vehicle/odometer-reading/reading/@value').getstringval() AS xml
FROM lm;