有這樣一個xml file,現在想用VB 修改黑體的屬性值,該怎么做呢?
<Recipe Path="d:\test.xml" NumberOfTests="4">
<AutomationSetting TestIds="0 1 2 3 4" EnableDieRegistration="False" IsReticle="False" />
<RecipeInfo MachineId="AAA" DeviceId="BBB" StepId="CCC" NotchDirection="2" NotchDirectionString="bottom" Radius="150" DieRegistrationRejectPercentage="80" ReticleSize="0 0" ReticleOrg="0 0" DieSize="20.791908 27.156754" FirstDieOrigin="-10.464208 -27.054075" Version="1010a" EdgeSize="3" CreateTime="03/05/2013 09:41:43" RecipeName="YECONCDCACMPM" CreateAuthor="" LastModifyTime="03/05/2013 17:36:16" LastModifyAuthor="" SoftwareVersion="2.0.2.31928" />
</Recipe>
先謝過了!
uj5u.com熱心網友回復:
參考xml,裝載xml檔案,selectsinglenode找到節點,setattribute設定屬性值uj5u.com熱心網友回復:
Dim values_element As IXMLDOMElementdim objNode as IXMLDOMNode
Set objNode = xmldoc.selectSingleNode("Recipe")
set values_element = objNode.setAttribute "Path","D:\file.xml"
這樣就把 <Recipe Path="d:\test.xml" NumberOfTests="4">的Path屬性設定為“D:\file.xml”
Ps:selectSingleNode的引數是有路徑要求的。
uj5u.com熱心網友回復:
Sub ChangeXML()
''.....
Set xmlNode = xmlDoc.selectSingleNode("Recipe//RecipeInfo")
With xmlNode
.setAttribute "MachineId", "aaa"
.setAttribute "DeviceId", "bbb"
.setAttribute "StepId", "ccc"
End With
''......
End Sub
uj5u.com熱心網友回復:
還少一個: Set xmlNode = xmlDoc.selectSingleNode("Recipe")
xmlNode.setAttribute "Path", "d:\123.xml"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/106504.html
標籤:VB基礎類
上一篇:if條件缺少&&邏輯運算子竟然還能運行,求大佬解釋下原理
下一篇:mshflexgrid換行的問題
