Buonasera, premetto che non conosco nulla di XML, ho la necessità di aggiungere ad un utility di terze parti un attributo sotto ad un determinato nodo.
Sono riuscito ad aggiungere l'attributo ma non capisco come poter fare affinche finisca sotto al nodo "elemento". In realtà viene aggiunto un nuovo nodo che si chiama "elemento" con l'attributo "idElement"

Grazie

Private Sub Command1_Click()
Dim dd As New DOMDocument
Dim root As IXMLDOMElement
Dim nd As IXMLDOMNode
Dim at As IXMLDOMAttribute
Dim attr As IXMLDOMAttribute
Dim doc As New MSXML2.DOMDocument
Dim node As MSXML2.IXMLDOMNode

Dim nodeList As MSXML2.IXMLDOMNodeList

Set nodeList = dd.selectNodes("//distinta/elementigrafici/elemento/")

'apre il file
dd.Load "c:\test.xml"


Set root = dd.documentElement

'crea elemento e attributo id

Set nd = dd.createElement("elemento")
Set at = dd.createAttribute("idElement")

nodeList.Item(4).appendChild nd


at.Value = "123456"

nd.Attributes.setNamedItem at


'salva il tutto
dd.save "c:\test.xml"
End Sub