2017-10-18 52 views
0

我有以下XMLMYSQL extractValue一起

<ns8:vehicles> 
       <ns8:vehicle vinNumber="asdaqwe" model="lambda" make="xdeee"> 
        <ns8:registration number="e123asdz23" date="2016-07-22"/> 
        <ns8:usage type="Passenger"/> 
       </ns8:vehicle> 
      </ns8:vehicles> 

,並試圖讓元素vinNumber和查詢 使用extractValue和註冊號,所以我做這樣的事情:

select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration') 
select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration number') 
select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration::number') 

沒有這些作品返回xpath錯誤或返回0數據。 我如何得到這個工作?

當XML呈現像它的工作:

<holder id="1"> 
    <title>Mr</title> 

所以當我輸入選擇extractValue一起(databasexmlfield, '// //持有標題') 它打印先生 MySQL的版本是最新的5.5

回答

0

嘗試:

SELECT 
    ExtractValue(@`xml`, '//ns8:vehicle/attribute::vinNumber'), 
    ExtractValue(@`xml`, '//ns8:vehicle/ns8:registration/attribute::number'); 

db-fiddle

相關問題