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(System.String) Constructor
XmlException(System.String, System.Exception, int, int) Constructor
XmlException(System.String, System.Exception) Constructor

XmlException Properties

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


XmlException() Constructor

public XmlException();

Summary

Constructs and initializes a new instance of the XmlException class.

Description

This constructor initializes the System.Xml.XmlException.Message property of the new instance to a system-supplied message that describes the error, such as "An XML error has occurred." This message takes into account the current system culture.

The System.Xml.XmlException.InnerException property is initialized to null . The System.Xml.XmlException.LineNumber and System.Xml.XmlException.LinePosition properties are initialized to zero.

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException(System.String) Constructor

public XmlException(string message);

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.

Description

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

The System.Xml.XmlException.InnerException property is initialized to null . The System.Xml.XmlException.LineNumber and System.Xml.XmlException.LinePosition properties are initialized to zero.

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException(System.String, System.Exception, int, int) Constructor

public XmlException(string message, Exception innerException, int lineNumber, int linePosition);

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 non-null, then the current Exception was raised in a catch block handling innerException .
lineNumber
A Int32 that specifies the line number where the error occurred.
linePosition
A Int32 that specifies the character position where the error occurred.

Description

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

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

See Also

System.Xml.XmlException Class, System.Xml Namespace

XmlException(System.String, System.Exception) 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