0
SELECT
XMLQUERY ('$x/test/xml[1]/data(@type)' PASSING XMLCOLUMN as "x") type,
XMLQUERY ('$x/test/xml[1]/text()' PASSING XMLCOLUMN as "x") text
FROM
XML
我想選擇父節點的所有子節點。我在思索着什麼看起來像這樣:xQuery數組[*]?
SELECT
XMLQUERY ('$x/test/xml[*]/data(@type)' PASSING XMLCOLUMN as "x") type,
XMLQUERY ('$x/test/xml[*]/text()' PASSING XMLCOLUMN as "x") text
FROM
XML
編輯: XML:
<test>
<xml type = 1>a</xml>
<xml type = 2>b</xml>
<xml type = 3>c</xml>
<xml type = 4>d</xml>
<xml type = 5>e</xml>
...
</test>
預期的結果:
type | text
-----|-----
1 | a
2 | b
3 | c
4 | d
...
直接子節點還是全部?看看http://stackoverflow.com/questions/5119655/xpath-to-get-all-child-nodes-elements-comments-and-text-without-parent,如果你要返回多個列,我推薦XMLTABLE而不是 –
XMLQUERY('$ x/xml [*]/child :: node()'傳遞XMLCOLUMN爲「x」)文本 給了我相同的結果 –
預期的結果是什麼? –