Home > Software engineering >  VB to read and modify XML node attribute value
VB to read and modify XML node attribute value

Time:10-03

There is such a XML file, and now want to use VB to modify properties of blackbody, how to do?




Thanked first!

CodePudding user response:

References to XML, loading XML documents, selectsinglenode find node, the setattribute set property values

CodePudding user response:

Dim values_element As IXMLDOMElement
Dim objNode as IXMLDOMNode
The Set objNode=xmldoc. SelectSingleNode (" Recipe ")
Set values_element=objNode. SetAttribute "Path", "D: \ file XML"
Thus the & lt; The Recipe Path="d: \ test XML" NumberOfTests="4" & gt; The Path attribute is set to "D: \ file XML"
Ps: there is a requirement for path selectSingleNode parameter is,

CodePudding user response:

 Sub ChangeXML () 
' '...
The Set xmlNode=xmlDoc. SelectSingleNode (" Recipe//RecipeInfo ")
With xmlNode
"SetAttribute MachineId", "aaa"
The setAttribute "DeviceId", "BBB"
The setAttribute "StepId", "CCC"
End With
"'...
End Sub

CodePudding user response:

Less a:
 Set xmlNode=xmlDoc. SelectSingleNode (" Recipe ") 
XmlNode. SetAttribute "Path", "d: \ 123. XML"
  • Related