惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
月光博客
月光博客
V
V2EX
PCI Perspectives
PCI Perspectives
Latest news
Latest news
博客园 - 三生石上(FineUI控件)
C
CERT Recently Published Vulnerability Notes
W
WeLiveSecurity
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Palo Alto Networks Blog
T
The Exploit Database - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
WordPress大学
WordPress大学
V
Vulnerabilities – Threatpost
H
Heimdal Security Blog
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - 叶小钗
V
Visual Studio Blog
Jina AI
Jina AI
P
Proofpoint News Feed
罗磊的独立博客
SecWiki News
SecWiki News
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 热门话题
Security Archives - TechRepublic
Security Archives - TechRepublic
The Hacker News
The Hacker News
Hugging Face - Blog
Hugging Face - Blog
N
News and Events Feed by Topic
NISL@THU
NISL@THU
T
Tailwind CSS Blog
T
Tenable Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Recent Announcements
Recent Announcements
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Tor Project blog
宝玉的分享
宝玉的分享
Help Net Security
Help Net Security
S
Security Affairs
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
G
GRAHAM CLULEY

博客园 - 恭喜发财

android 电话状态的监听(来电和去电) (转)sql:variable() binding and modify method of xquery: insert XML DML 在WinForm中控制GIF动画的启停的一种方法(转) SQL Server Backup file in standard Zip format Working with binary large objects (BLOBs) c# 得到局域网中可用SqlServer服务器列表(转) C#实现UDP协议(转) 健康大讲堂—凡膳皆药 寓医于食 ReportView(RDSL)参考资料 How To Print Using Custom Page Sizes on Windows NT and Windows 2000(VB6) 汇总c#.net常用函数和方法集 在多线程中如何调用Winform 使用C#在进度条中显示复制文件的进度(转) c#将大文件读取或写入到数据库(带进度条的源码)(转) 写C#自定义控件的心得 Finalize(析构函数)、Dispose、Close 的区别与使用 如何在WinForm中对DataGrid进行分页显示(转) 如何用C#做一个类似于桌面插件的程序(转) c#连接各类数据库大全
(转)Xml DML - 恭喜发财 - 博客园
恭喜发财 · 2010-04-26 · via 博客园 - 恭喜发财

declare @myxml xml
set @myxml='<?xml version="1.0" encoding="gb2312"?>
            <root>
               <item id="1">
               </item>
            </root>
'
select @myxml--1、插入item的第一个子元素
  set @myxml.modify('insert <course1>sql server2005</course1>  into (root/item)[1]') select @myxml
--2、插入item的第一个子元素,插入到同级子元素前面
  set @myxml.modify('insert <sname> 王一诺</sname> as first into (root/item)[1]') select @myxml
--3、插入item的第一个子元素,插入到同级子元素后面
  set @myxml.modify('insert <grade>82</grade> as last into (root/item)[1]') select @myxml
--4、插入第二个item节点
  set @myxml.modify('insert <item id="2" year="2009"></item> into (/root)[1]'select @myxml
--或者
  set @myxml.modify('insert <item id="2" year="2009"></item> after (/root/item)[1]')
--5、向第二个item节点插入多个元素
  set @myxml.modify('insert (<sname>王海</sname>,<course1>sql server2005</course1>,<grade>75</grade>) into (/root/item)[2]')
--6、插入属性
  set @myxml.modify('insert attribute year{"2009"} into (/root/item)[1]')
select @myxml
--7、插入多个属性
  set @myxml.modify('insert (attribute depart{"计算机"},attribute class{"1班"}) into (/root/item)[1]')
--8、插入文本节点
  set @myxml.modify('insert text{"成绩表"} as first into  (/root)[1]'--9、插入整个节点
  set @myxml.modify('insert <item id="3"  year="2009">
                           <sname>王若天</sname>
                           <course1>oracle</course1>
                           <grade>59</grade></item>
                     into (/root)[1]
')
--10、插入处理指令
SET @myxml.modify('insert <?Program ="Instructions.exe" ?> before (/root)[1] ')  
select @myxml
二、删除操作
declare @myxml xml
set @myxml='<?Program ="Instructions.exe" ?>
          <root>成绩表--这是个文本节点
             <item id="1" year="2009" depart="计算机" class="1班">
               <sname> 王一诺</sname>
               <course1>sql server2005</course1>
               <grade>82</grade>
             </item>
             <item id="2" year="2009" class="1班">
               <sname>王海</sname>
               <course1>sql server2005</course1>
               <grade>75</grade></item>
             <item id="3" year="2009" class="1班">
               <sname>王若天</sname>
               <course1>oracle</course1>
               <grade>59</grade>
             </item>
           </root>
'--1、删除所有指令
set @myxml.modify('delete //processing-instruction()')
select '删除所有指令'=@myxml
--2、删除文本节点
set @myxml.modify('delete /root/text()')
select '删除文本节点'=@myxml
--3、删除节点id为的属性
set @myxml.modify('delete /root/item[@id=1]/@class')
select '删除节点id为的属性'=@myxml
--4、删除第二个节点属性
set @myxml.modify('delete /root/item[2]/@class')
select '删除第二个节点属性'=@myxml
--5、删除节点属性
set @myxml.modify('delete /root/item/@class')
select '删除节点属性'=@myxml
--6、删除节点id为的元素
set @myxml.modify('delete /root/item[@id=1]/grade')
select '删除节点id为的元素'=@myxml
--7、删除第二个节点元素
set @myxml.modify('delete /root/item[2]/grade')
select '删除第二个节点元素'=@myxml
--8、删除元素
set @myxml.modify('delete /root/item/grade')
select '删除元素'=@myxml
--9、删除id为的节点
set @myxml.modify('delete /root/item[@id=2]')
select '删除id为的节点'=@myxml
--10、删除第二个的节点
set @myxml.modify('delete /root/item[2]')
select '删除id为的节点'=@myxml
--11、删除第二个节点
set @myxml.modify('delete /root/item')
select '删除节点'=@myxml
三、修改操作
--1、修改文本的值
set @myxml.modify('replace value of(/root/text())[1] with "1班成绩表"')
select @myxml
--2、修改元素的值
set @myxml.modify('replace value of(/root/item[@id=3]/grade/text())[1] with "60"')
select @myxml
--3、修改属性的值
set @myxml.modify('replace value of(/root/item[@id=1]/@class)[1] with "2班"')
select @myxml