XmlReader.IsDefault Proprietà

Definizione

In caso di override in una classe derivata, ottiene un valore che indica se il nodo corrente è un attributo generato dal valore predefinito definito nel DTD o nello schema.

public:
 virtual property bool IsDefault { bool get(); };
public:
 abstract property bool IsDefault { bool get(); };
public virtual bool IsDefault { get; }
public abstract bool IsDefault { get; }
member this.IsDefault : bool
Public Overridable ReadOnly Property IsDefault As Boolean
Public MustOverride ReadOnly Property IsDefault As Boolean

Valore della proprietà

true se il nodo corrente è un attributo il cui valore è stato generato dal valore predefinito definito nel DTD o nello schema; false se il valore dell'attributo è stato impostato in modo esplicito.

Eccezioni

È stato chiamato un XmlReader metodo prima del completamento di un'operazione asincrona precedente. In questo caso, InvalidOperationException viene generata con il messaggio "Un'operazione asincrona è già in corso".

Esempio

Nell'esempio seguente vengono visualizzati tutti gli attributi nell'elemento radice.

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

public class Sample
{
  public static void Main(){

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

    reader.MoveToContent();

    // 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.
    reader.Close();

  }
} // End class

Nell'esempio vengono usati i file seguenti come input.

book4.xml

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

book.dtd

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

Commenti

IsDefault restituisce false sempre per le implementazioni di XmlReader che non supportano lo schema o le informazioni DTD. Questa proprietà si applica solo a un nodo attributo.

Si applica a