File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
snippets/visualbasic/VS_Snippets_Data/Classic WebData XmlDocument.CreateElement Example/VB Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -6,23 +6,31 @@ Imports System.IO
6
6
Imports System.Xml
7
7
8
8
Public Class Sample
9
-
9
+
10
10
Public Shared Sub Main()
11
11
'Create the XmlDocument.
12
12
Dim doc As New XmlDocument()
13
13
doc.LoadXml( "<book genre='novel' ISBN='1-861001-57-5'>" & _
14
14
"<title>Pride And Prejudice</title>" & _
15
15
"</book>" )
16
-
16
+
17
17
'Create a new node and add it to the document.
18
18
'The text node is the content of the price element.
19
19
Dim elem As XmlElement = doc.CreateElement( "price" )
20
20
Dim text As XmlText = doc.CreateTextNode( "19.95" )
21
21
doc.DocumentElement.AppendChild(elem)
22
22
doc.DocumentElement.LastChild.AppendChild(text)
23
-
23
+
24
24
Console.WriteLine( "Display the modified XML..." )
25
25
doc.Save(Console.Out)
26
26
End Sub
27
27
End Class
28
+ ' The example displays the following output:
29
+ '
30
+ ' Display the modified XML...
31
+ ' <?xml version="1.0" encoding="utf-8"?>
32
+ ' <book genre="novel" ISBN="1-861001-57-5">
33
+ ' <title>Pride And Prejudice</title>
34
+ ' <price>19.95</price>
35
+ ' </book>
28
36
' </Snippet1>
You can’t perform that action at this time.
0 commit comments