forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.vb
31 lines (23 loc) · 836 Bytes
/
source.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
' <Snippet1>
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim doc As New XmlDocument()
doc.Load("2books.xml")
' Create a new element.
Dim elem As XmlElement = doc.CreateElement("misc")
elem.InnerText = "hardcover"
elem.SetAttribute("publisher", "WorldWide Publishing")
' Clone the element so we can add one to each of the book nodes.
Dim elem2 As XmlNode = elem.CloneNode(True)
' Add the new elements.
doc.DocumentElement.FirstChild.AppendChild(elem)
doc.DocumentElement.LastChild.AppendChild(elem2)
Console.WriteLine("Display the modified XML...")
doc.Save(Console.Out)
End Sub
End Class
' </Snippet1>