IsDefault Property

XmlReader::IsDefault Property


When overridden in a derived class, gets a value indicating whether the current node is an attribute that was generated from the default value defined in the DTD or schema.

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

property bool IsDefault {
	virtual bool get();

Property Value

Type: System::Boolean

true if the current node is an attribute whose value was generated from the default value defined in the DTD or schema; false if the attribute value was explicitly set.

Exception Condition

An XmlReader method was called before a previous asynchronous operation finished. In this case, InvalidOperationException is thrown with the message “An asynchronous operation is already in progress.”

IsDefault always returns false for implementations of XmlReader that do not support schema or DTD information. This property applies only to an attribute node.

The following example displays all attributes on the root element.

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

public class Sample 
  public static void Main(){

    // Create the reader.
    XmlReader reader = XmlReader.Create("book4.xml");


    // Display each of the attribute nodes, including default attributes.
    while (reader.MoveToNextAttribute()){
        if (reader.IsDefault)
          Console.Write("(default attribute) ");
        Console.WriteLine("{0} = {1}", reader.Name, reader.Value);  

    //Close the reader.

} // End class

The example uses the following files as input.


<!DOCTYPE book SYSTEM 'book.dtd'>
<book ISBN = '1-861001-57-5'>
  <title>Pride And Prejudice</title>


<!ELEMENT book (title,price)> 
<!ATTLIST book 
   genre CDATA "novel"
<!ELEMENT title (#PCDATA)>
<!ELEMENT price (#PCDATA)>

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft