Reputation: 2241
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.
Upvotes: 2
Views: 4192
Reputation: 93
Remove the attribute from the Attributes collection of the node in question:
oNode.Attributes.removeNamedItem "generated"
Upvotes: 4
Reputation: 35477
To remove an attribute from an node:
oNode.removeAttribute("generated");
To save the changes:
oDoc.save("changed.xml")
Upvotes: 0