提取xml文件的内容
问题描述:
我有一个来自crmod(oracle crm on demand)的xml文件,并且想提取记录数。 (即17680)通过查询到表中。我可以提取XML中的其他标签接受记录计数。能在正确的方向有人点提取xml文件的内容
<ListOfAllotmentUsage xmlns="urn:/crmondemand/xml/AllotmentUsage/Data" recordcount="17680" lastpage="false">
亲切的问候
莱昂
答
您应该使用@
指定的属性。
使用XMLTABLE,
SELECT *
FROM xmltable(
xmlnamespaces(DEFAULT 'urn:/crmondemand/xml/AllotmentUsage/Data'),'ListOfAllotmentUsage'
passing xmltype('<ListOfAllotmentUsage xmlns="urn:/crmondemand/xml/AllotmentUsage/Data" recordcount="17680" lastpage="false"></ListOfAllotmentUsage>')
columns
rec_count NUMBER path '@recordcount'
);
使用extractValue一起,
SELECT extractvalue(
xmltype('<ListOfAllotmentUsage xmlns="urn:/crmondemand/xml/AllotmentUsage/Data" recordcount="17680" lastpage="false"></ListOfAllotmentUsage>'),
'ListOfAllotmentUsage/@recordcount',
'xmlns="urn:/crmondemand/xml/AllotmentUsage/Data"'
)
FROM dual;