XmlValidatingReader.IsDefault Propriedade

Definição

Obtém um valor que indica se o nó atual é um atributo que foi gerado com base no valor padrão definido na DTD (definição de tipo de documento) ou no esquema.

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

Valor da propriedade

Boolean

true se o nó atual for um atributo cujo valor foi gerado a partir do valor padrão definido no DTD ou no esquema; false se o valor do atributo foi definido explicitamente.

Exemplos

O exemplo a seguir exibe todos os nós de atributos no elemento raiz.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   // Create the reader.
   XmlTextReader^ txtreader = gcnew XmlTextReader( "book4.xml" );
   XmlValidatingReader^ reader = gcnew XmlValidatingReader( txtreader );
   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();
}

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

public class Sample
{
  public static void Main(){

    //Create the reader.
    XmlTextReader txtreader = new XmlTextReader("book4.xml");
    XmlValidatingReader reader = new XmlValidatingReader(txtreader);

    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
Imports System.IO
Imports System.Xml

public class Sample 

  public shared sub Main()

    'Create the reader.
    Dim txtreader as XmlTextReader = new XmlTextReader("book4.xml")
    Dim reader as XmlValidatingReader = new XmlValidatingReader(txtreader)

    reader.MoveToContent()

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

O exemplo usa os arquivos a seguir como entrada.

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)>

Comentários

Essa propriedade se aplica apenas a um nó de atributo.

Observação

A XmlValidatingReader classe está obsoleta no .NET Framework 2.0. Você pode criar uma instância de validação XmlReader usando a XmlReaderSettings classe e o Create método. Para obter mais informações, consulte a seção de Comentários da página de referência XmlReader.

Aplica-se a

Confira também