更新时间:2023-09-23 18:00:52
这是您可以开始使用的基本代码.
Here's the basic code you can start with.
Imports System.Xml
Public Class Form1
Private Sub Test()
Dim xDoc As XmlDocument
Dim root As XmlNode
Dim n As XmlNode
xDoc = New XmlDocument()
xDoc.Load("F:\tmp\a.xml")
root = xDoc.SelectSingleNode("/ApplicationSettings")
If xDoc.SelectSingleNode("/ApplicationSettings/NodeToBeAdded1") _
Is Nothing Then
n = root.InsertAfter(
xDoc.CreateNode(XmlNodeType.Element, "NodeToBeAdded1", ""),
xDoc.SelectSingleNode("/ApplicationSettings/Schema"))
n.AppendChild(
xDoc.CreateNode(XmlNodeType.Element, "XMLSubSomething", ""))
End If
xDoc.Save("F:\tmp\b.xml")
End Sub
End Class