SQL获取XML节点信息

DECLARE @xml XML;

DECLARE @totle_Count INT

SET @xml = '

<BetModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <msgmodel>

    <context>1213</context>

    <wxId>15415</wxId>

    <MsID>1351653</MsID>

    <NickName>测试</NickName>

  </msgmodel>

  <msgmodel>

    <context>1213</context>

    <wxId>15415</wxId>

    <MsID>1351653</MsID>

    <NickName>测试</NickName>

  </msgmodel>

  <msgmodel>

    <context>1213</context>

    <wxId>15415</wxId>

    <MsID>1351653</MsID>

    <NickName>测试</NickName>

  </msgmodel>

  <isBeginBet>true</isBeginBet>

  <isStopBet>true</isStopBet>

  <isOpen>true</isOpen>

  <ClientID>1</ClientID>

  <SeveralBoots>1</SeveralBoots>

  <SeveralBootsNum>1</SeveralBootsNum>

  <TableNo>1</TableNo>

  <CaseZhuang>0</CaseZhuang>

  <CaseIdel>0</CaseIdel>

  <CaseHe>0</CaseHe>

  <CaseSubZhuang>0</CaseSubZhuang>

  <CaseSubIdle>0</CaseSubIdle>

</BetModel>';



/*获取节点内容*/

SELECT @xml.value('(//BetModel/isBeginBet/text())[1]','varchar(200)') isBeginBet



/*获取节点数*/

SELECT (select @xml.value('count(//msgmodel)','int')) msgmodelcount


猜你喜欢

转载自blog.csdn.net/weixin_44315658/article/details/85322730