简体   繁体   English

如何提取xml列的元素?

[英]How do I extract the elements of xml column?

How do I extract the elements to xml column? 如何将元素提取到xml列?

<V>
  <r>
    <ID>alkj</ID>
    <Date>2013-01-02T00:00:00-02:00</Date>
    <Value>97429.91</Value>
  </r>
  <r>
    <ID>asdf</ID>
    <Date>2014-01-02T00:00:00-02:00</Date>
    <Value>90121.18</Value>
  </r>
<V>

need only what is inside the element v, the return needs to be: 只需要元素v内的内容,返回值应该是:

<r>
    <ID>alkj</ID>
    <Date>2013-01-02T00:00:00-02:00</Date>
    <Value>97429.91</Value>
  </r>
  <r>
    <ID>asdf</ID>
    <Date>2014-01-02T00:00:00-02:00</Date>
    <Value>90121.18</Value>
</r>

but I can not use 但我不能使用

select colunaxml.query('(/v/r)') from tabela

because V is not always V ! 因为V并不总是V but the internal elements are always r 但是内部元素总是r

thank for help! 谢谢帮忙!

SELECT colunaxml.query('(/*/r)')

如果您已经知道父元素名称始终是<v><a><b><c> ,则在指定它们时XPath的执行速度可能会更快:

SELECT colunaxml.query('(/(v | a | b | c)/r)')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM