XmlElementEventHandler Delegate

 

Represents the method that handles the UnknownElement event of an XmlSerializer.

Namespace:   System.Xml.Serialization
Assembly:  System.Xml (in System.Xml.dll)

type XmlElementEventHandler = 
    delegate of 
        sender:Object *
        e:XmlElementEventArgs -> unit

Parameters

sender
Type: System.Object

The source of the event.

e
Type: System.Xml.Serialization.XmlElementEventArgs

A XmlElementEventArgs that contains the event data.

When you create an XmlElementEventHandler delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see NIB: Events and Delegates.

The UnknownElement event occurs only when you call the Deserialize method.

The following example deserializes a class named Group from a file named UnknownElements.xml. Whenever an element is found in the file that has no corresponding member in the class, the UnknownElement event occurs. To try the example, paste the following XML code into a file named UnknownElements.xml.

<?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">
  <GroupName>MyGroup</GroupName>
  <GroupSize>Large</GroupSize>
  <GroupNumber>444</GroupNumber>
  <GroupBase>West</GroupBase>
</Group>
No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: