Hi all,
Any assistance in this matter would be very much appreciated. I have googled the subject to bits but can't seem to be able to get my head round appending children to existing elements.
I currently have an XML file (See below) that has a list of engagement numbers.
<?xml version="1.0" encoding="UTF-8"?>
<Preference>
<ChargeOut>40.00</ChargeOut>
<TimesheetCost>0.80</TimesheetCost>
<EngagementNumbers>
<EngItem>892875</EngItem>
<EngItem>962114</EngItem>
</EngagementNumbers>
</Preference>
A user populates a new "EngItem" on a user form and clicks update at which point the following code is run:-
If Frm_PASORefs.txPASOAdd.Value = "" Then Exit Sub
Dim objXML As MSXML2.DOMDocument
Set objXML = New MSXML2.DOMDocument
objXML.Load (ActiveWorkbook.Path & "\MyXml.xml")
Dim oEngNum As MSXML2.IXMLDOMNode
Set oEngNum = objXML.createElement("EngItem")
oEngNum.appendChild objXML.createTextNode(myVariable)
Dim cnode As MSXML2.IXMLDOMNode
Set cnode = objXML.createElement("EngagementNumbers")
cnode.appendChild oEngNum
objXML.Save (ThisWorkbook.Path & "\MyXml.xml")
I was hoping that this would update the <EngagementNumbers> element and append another <EngItem> as a child.
Thanks for your help in advance.
Stuart
Bookmarks