16,554
社区成员
发帖
与我相关
我的任务
分享
Dim doc As New System.Xml.XmlDocument
doc.Load("E:\工程\读取xml\book.XML")
Dim root As Xml.XmlNode
root = doc.SelectSingleNode("bookstore")
Dim gy As Xml.XmlElement = doc.CreateElement("book")
gy.SetAttribute("genre", "1")
gy.SetAttribute("ISBN", "1-3-1-4")
Dim st As Xml.XmlElement = doc.CreateElement("title")
st.InnerText = "CS入门到精通"
gy.AppendChild(st)
Dim st1 As Xml.XmlElement = doc.CreateElement("作者")
st1.InnerText = "gy"
gy.AppendChild(st1)
Dim st2 As Xml.XmlElement = doc.CreateElement("价格")
st2.InnerText = "10.00"
gy.AppendChild(st2)
root.AppendChild(gy)
doc.Save("E:\工程\读取xml\book.XML")
MsgBox("增加节点成功!", MsgBoxStyle.Information, "XML")