sql xml 查询指定节点值,以及节点属性值

SELECT   top 10  [HFMBDATA].query('(/Items/Item[@ID=''tbBryj''])').value('(//TextValue)[1]','nvarchar(max)') as mz,

[HFMBDATA].value('(Items/Item[@ID="rb_fzhd_y"]/@ControlType)[1]','varchar(50)')   FROM [EMRCP].[dbo].[T_ZYBR_HF] as at

获取结果:

mz        at
无         CheckBox.RadioBox

 

 

示例XML(HFMBDATA)

<Items>
  <Item ID="rb_cyhhjzk_h" Name="cyhhjzk" ControlType="CheckBox.RadioBox" Value="" Checked="True">
    <TextValue>好</TextValue>
  </Item>
  <Item ID="rb_cyhhjzk_yb" Name="cyhhjzk" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>一般</TextValue>
  </Item>
  <Item ID="rb_cyhhjzk_bh" Name="cyhhjzk" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>不好</TextValue>
  </Item>
  <Item ID="rb_sy_h" Name="sy" ControlType="CheckBox.RadioBox" Value="" Checked="True">
    <TextValue>好</TextValue>
  </Item>
  <Item ID="rb_sy_yb" Name="sy" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>一般</TextValue>
  </Item>
  <Item ID="rb_sy_bh" Name="sy" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>不好</TextValue>
  </Item>
  <Item ID="rb_asfy_y" Name="asfy" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>有</TextValue>
  </Item>
  <Item ID="rb_asfy_my" Name="asfy" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>没有</TextValue>
  </Item>
  <Item ID="rb_cxzz_y" Name="cxzz" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>有</TextValue>
  </Item>
  <Item ID="rb_cxzz_my" Name="cxzz" ControlType="CheckBox.RadioBox" Value="" Checked="False">
    <TextValue>没有</TextValue>
  </Item>
  <Item ID="tbBryj" Name="" ControlType="InputField.Text" Value="">
    <TextValue>无</TextValue>
    <Items />
  </Item>
  <Item ID="tb_hfryyj" Name="" ControlType="InputField.Text" Value="">
    <TextValue>无</TextValue>
    <Items />
  </Item>
  <Item ID="tb_yshfyj" Name="" ControlType="InputField.Text" Value="">
    <TextValue>无</TextValue>
    <Items />
  </Item>
</Items>

 

转载于:https://www.cnblogs.com/chuhaida/p/4586200.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值