System.Xml.XmlException Class

public class XmlException : SystemException

Base Types

Object
  Exception
    SystemException
      XmlException

Assembly

System.Xml

Library

XML

Summary

Represents the error that occurs when an XML document or fragment cannot be parsed.

See Also

System.Xml Namespace

Members

XmlException Constructors

XmlException Constructor

XmlException Properties

XmlException.LineNumber Property
XmlException.LinePosition Property
XmlException.Message Property


XmlException Constructor

public XmlException(string message, Exception innerException);

Summary

Constructs and initializes a new instance of the XmlException class.

Parameters

message
A String that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.
innerException
An instance of Exception that is the cause of the current exception. If innerException is not a null reference, the current exception was raised in a catch block handling innerException.

Description

This constructor initializes the System.Xml.XmlException.Message property of the new instance using message and the System.Xml.XmlException.InnerException property using innerException. If the message parameter is null , the System.Xml.XmlException.Message property is set to the system-supplied message provided by the constructor that takes no arguments.

The System.Xml.XmlException.LineNumber and System.Xml.XmlException.LinePosition properties are initialized to zero.

[Note: For more information on inner exceptions, see System.Exception.InnerException.]

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException.LineNumber Property

public int LineNumber { get; }

Summary

Gets the line number where the error occurred.

Property Value

A Int32 containing the line number where the error occurred.

Description

This property is read-only.

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException.LinePosition Property

public int LinePosition { get; }

Summary

Gets the character position where the error occurred.

Property Value

A Int32 containing the character position where the error occurred.

Description

This property is read-only.

The first character in the line is in position 1. Note that white space characters at the start of the line are not skipped.

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException.Message Property

public override string Message { get; }

Summary

Gets the error message that describes the current exception.

Property Value

A String containing the error message that describes the current exception.

Description

This property is read-only.

If the System.Xml.XmlException.LineNumber property is not equal to zero, the string returned by this property includes the values of the System.Xml.XmlException.LineNumber and System.Xml.XmlException.LinePosition properties.

[Note: This property overrides System.Exception.Message.]

See Also

System.Xml.XmlException Class, System.Xml Namespace