What is the easiest way of removing the attribute of a node of an xml file in vb?
I'm familiar with using the MSXML2 library for reading xml files. But is there an easy way 开发者_开发问答of editing a particular node. Say I have the following line of code that selects a dataroot
element that has the attribute generated
:
Dim oDoc as MSXML2.DOMDocument
Dim oNode as MSXML2.IXMLDOMNode
Set oDoc = ... //open xml file here//
Set oNode = oDoc.selectSingleNode("/root/dataroot/[@generated]")
I want to be able to remove the generated
attribute from the selected node and save the change back to the original file.
Remove the attribute from the Attributes collection of the node in question:
oNode.Attributes.removeNamedItem "generated"
To remove an attribute from an node:
oNode.removeAttribute("generated");
To save the changes:
oDoc.save("changed.xml")
精彩评论