Gets an XmlAttributeCollection containing the attributes of this node.
Option Strict
Option Explicit
Imports System
Imports System.IO
Imports System.Xml
Public Class Sample
Public Shared Sub Main()
Dim doc As New XmlDocument()
doc.LoadXml("<book xmlns:bk='urn:samples' bk:ISBN='1-111111-57-5'>" & _
"<title>C#</title>" & _
"</book>")
Dim root As XmlNode = doc.FirstChild
Dim ns As String = root.GetNamespaceOfPrefix("bk")
Dim attr As XmlNode = doc.CreateNode(XmlNodeType.Attribute, "genre", ns)
attr.Value = "Computer"
root.Attributes.SetNamedItem(attr)
doc.Save(Console.Out)
End Sub 'Main
End Class 'Sample
Related examples in the same category