XmlReader.IsDefault XmlReader.IsDefault XmlReader.IsDefault XmlReader.IsDefault Property

定义

当在派生类中被重写时,获取一个值,该值指示当前节点是否是从 DTD 或架构中定义的默认值生成的特性。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.

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

属性值

如果当前节点是其值从 DTD 或架构中定义的默认值生成的属性,则为 true;如果属性值为显式设置的,则为 falsetrue 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.

异常

在上一次异步操作完成之前调用了 XmlReader 方法。An XmlReader method was called before a previous asynchronous operation finished. 在此情况下,会引发 InvalidOperationException 并显示消息“异步操作已在进行中。”In this case, InvalidOperationException is thrown with the message "An asynchronous operation is already in progress."

示例

下面的示例显示根元素上的所有属性。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");  
  
    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  

该示例使用以下文件作为输入。The example uses the following files as 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)>  

注解

IsDefault对于不false支持架构或XmlReader DTD 信息的实现,始终返回。IsDefault always returns false for implementations of XmlReader that do not support schema or DTD information. 此属性仅适用于属性节点。This property applies only to an attribute node.

适用于