This documentation is archived and is not being maintained.

XmlNodeEventArgs.LineNumber Property

Gets the line number of the unknown XML node.

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

public int LineNumber { get; }

Property Value

Type: System.Int32
The line number of the unknown XML node.

using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

public class Group{
   // Only the GroupName field will be known.
   public string GroupName;

public class Test{
   static void Main(){
      Test t = new Test();

   private void DeserializeObject(string filename){
      XmlSerializer mySerializer = new XmlSerializer(typeof(Group));
      FileStream fs = new FileStream(filename, FileMode.Open);
      mySerializer.UnknownNode += new 
      Group myGroup = (Group) mySerializer.Deserialize(fs);
   private void serializer_UnknownNode
   (object sender, XmlNodeEventArgs e){
      ("UnknownNode Name: {0}", e.Name);
      ("UnknownNode LocalName: {0}" ,e.LocalName);
      ("UnknownNode Namespace URI: {0}", e.NamespaceURI);
      ("UnknownNode Text: {0}", e.Text);

      XmlNodeType myNodeType = e.NodeType;
      Console.WriteLine("NodeType: {0}", myNodeType);

      Group myGroup = (Group) e.ObjectBeingDeserialized;
      Console.WriteLine("GroupName: {0}", myGroup.GroupName);
/* Paste this XML into a file named UnknownNodes:
<?xml version="1.0" encoding="utf-8"?>
<Group xmlns:xsi="" 

xmlns:xsd="" xmlns:coho = "" 


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.