站内搜索:
首页 >> 前端 >> 内容
xml modify

时间:2013/11/21 14:56:48

*我在VB 里用SQL 进行UPDATE 时, 如果XML里的某个属性为空就无法UPDATE

 

 

replace value of XML DML 语句以下示例说明如何在 XML 文档中更新节点。  
  
在以下示例中,首先将文档实例分配给 xml 类型的变量。然后,replace value of XML DML 语句将更新文档中的值。  
  
DECLARE @myDoc xml  
SET @myDoc = '<Root>  
<Location LocationID="10"   
            LaborHours="1.1"  
            MachineHours=".2" >Manufacturing steps are described here.  
<step>Manufacturing step 1 at this work center</step>  
<step>Manufacturing step 2 at this work center</step>  
</Location>  
</Root>'  
SELECT @myDoc  
  
-- update text in the first manufacturing step  
SET @myDoc.modify('  
  replace value of (/Root/Location/step[1]/text())[1]  
  with     "new text describing the manu step"  
')  
SELECT @myDoc  
-- update attribute value  
SET @myDoc.modify('  
  replace value of (/Root/Location/@LaborHours)[1]  
  with     "100.0"  
')  
SELECT @myDoc  

 

 

  • 上一篇:Southeastern Europe 2004
  • 下一篇:Cookie的简单使用
  • 返回顶部