XmlNodeEventArgs Class
Provides data for the UnknownNode event.
Assembly: System.Xml (in System.Xml.dll)
The XmlNodeEventArgs type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | LineNumber | Gets the line number of the unknown XML node. |
![]() ![]() | LinePosition | Gets the position in the line of the unknown XML node. |
![]() ![]() | LocalName | Gets the XML local name of the XML node being deserialized. |
![]() ![]() | Name | Gets the name of the XML node being deserialized. |
![]() ![]() | NamespaceURI | Gets the namespace URI that is associated with the XML node being deserialized. |
![]() ![]() | NodeType | Gets the type of the XML node being deserialized. |
![]() ![]() | ObjectBeingDeserialized | Gets the object being deserialized. |
![]() ![]() | Text | Gets the text of the XML node being deserialized. |
| Name | Description | |
|---|---|---|
![]() ![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
For more information about handling events, see Consuming Events.
The UnknownNode event can occur only when you call the Deserialize method.
The following example uses the UnknownNode event of the XmlSerializer to print various properties of an unknown XML node that is encountered when calling the XmlSerializer class's Deserialize method.
Imports System Imports System.IO Imports System.Xml Imports System.Xml.Serialization Public Class Group ' Only the GroupName field will be known. Public GroupName As String End Class Public Class Test Shared Sub Main() Dim t As Test = New Test() t.DeserializeObject("UnknownNodes.xml") End Sub Private Sub DeserializeObject(filename As String ) Dim mySerializer As XmlSerializer = New XmlSerializer(GetType(Group)) Dim fs As FileStream = New FileStream(filename, FileMode.Open) AddHandler mySerializer.UnknownNode, _ AddressOf serializer_UnknownNode Dim myGroup As Group = _ CType(mySerializer.Deserialize(fs), Group) fs.Close() End Sub Private Sub serializer_UnknownNode _ (sender As object , e As XmlNodeEventArgs ) Console.WriteLine _ ("UnknownNode Name: {0}", e.Name) Console.WriteLine _ ("UnknownNode LocalName: {0}" ,e.LocalName) Console.WriteLine _ ("UnknownNode Namespace URI: {0}", e.NamespaceURI) Console.WriteLine _ ("UnknownNode Text: {0}", e.Text) Dim myNodeType As XmlNodeType = e.NodeType Console.WriteLine("NodeType: {0}", myNodeType) Dim myGroup As Group = CType(e.ObjectBeingDeserialized, Group) Console.WriteLine("GroupName: {0}", myGroup.GroupName) Console.WriteLine() End Sub End Class ' Paste this XML into a file named UnknownNodes: '<?xml version="1.0" encoding="utf-8"?> '<Group xmlns:xsi="http:'www.w3.org/2001/XMLSchema-instance" 'xmlns:xsd="http:'www.w3.org/2001/XMLSchema" xmlns:coho = "http:'www.cohowinery.com" 'xmlns:cp="http:'www.cpandl.com"> ' <coho:GroupName>MyGroup</coho:GroupName> ' <cp:GroupSize>Large</cp:GroupSize> ' <cp:GroupNumber>444</cp:GroupNumber> ' <coho:GroupBase>West</coho:GroupBase> ' <coho:ThingInfo> ' <Number>1</Number> ' <Name>Thing1</Name> ' <Elmo> ' <Glue>element</Glue> ' </Elmo> ' </coho:ThingInfo> '/Group>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.



