I would like to create a new XML node to append to an existing one in my XML file.
Specifically, the structure of the file is:
<contract>
<trade></trade>
<trade></trade>
</contract>
My idea is to get each <trade>
node and append a new child to it.
This child should look like this:
<tradeSource></tradeSource>
My question is, how do I define this new child to append? It doesn't seem I can find the right object to create on VBA (although the library MSXML v3.0 has been referenced in the project) and I don't manage to find such a sample of brand-new node anywhere on the web. My pseudo-code:
XMLFile.Load(myFileFullName)
Set tradeNodes = XMLFile.getElementsByTagName("trade")
For Each trade In tradeNodes
Set newNode = ???? '<-- how to fill this?
trade.appendChild(newNode)
Next trade
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…