本文整理汇总了VB.NET中System.Xml.XmlNodeChangedEventHandler代理的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlNodeChangedEventHandler代理的具体用法?VB.NET XmlNodeChangedEventHandler怎么用?VB.NET XmlNodeChangedEventHandler使用的例子?那么恭喜您, 这里精选的代理代码示例或许可以为您提供帮助。
在下文中一共展示了XmlNodeChangedEventHandler代理的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.IO
Imports System.Xml
Namespace Microsoft.Samples.Xml
Public Class Sample
Private Const filename As String = "book.xml"
Public Shared Sub Main()
Dim mySample As Sample = New Sample()
mySample.Run(filename)
End Sub
Public Sub Run(ByVal args As String)
' Create and load the XML document.
Console.WriteLine("Loading file {0} ...", args)
Dim doc As XmlDocument = New XmlDocument()
doc.Load(args)
'Create the event handlers.
AddHandler doc.NodeChanged, AddressOf MyNodeChangedEvent
AddHandler doc.NodeInserted, AddressOf MyNodeInsertedEvent
' Change the book price.
doc.DocumentElement.LastChild.InnerText = "5.95"
' Add a new element.
Dim newElem As XmlElement = doc.CreateElement("style")
newElem.InnerText = "hardcover"
doc.DocumentElement.AppendChild(newElem)
Console.WriteLine()
Console.WriteLine("Display the modified XML...")
Console.WriteLine(doc.OuterXml)
End Sub
' Handle the NodeChanged event.
Private Sub MyNodeChangedEvent(ByVal source As Object, ByVal args As XmlNodeChangedEventArgs)
Console.Write("Node Changed Event: <{0}> changed", args.Node.Name)
If Not (args.Node.Value Is Nothing) Then
Console.WriteLine(" with value {0}", args.Node.Value)
Else
Console.WriteLine("")
End If
End Sub
' Handle the NodeInserted event.
Private Sub MyNodeInsertedEvent(ByVal source As Object, ByVal args As XmlNodeChangedEventArgs)
Console.Write("Node Inserted Event: <{0}> inserted", args.Node.Name)
If Not (args.Node.Value Is Nothing) Then
Console.WriteLine(" with value {0}", args.Node.Value)
Else
Console.WriteLine("")
End If
End Sub
End Class
End Namespace