Export (0) Print
Expand All

XmlReader.HasAttributes Property

Gets a value indicating whether the current node has any attributes.

[Visual Basic]
Public Overridable ReadOnly Property HasAttributes As Boolean
[C#]
public virtual bool HasAttributes {get;}
[C++]
public: __property virtual bool get_HasAttributes();
[JScript]
public function get HasAttributes() : Boolean;

Property Value

true if the current node has attributes; otherwise, false.

Example

[Visual Basic, C#, C++] The following example displays all attributes on the current node.

[Visual Basic] 
Public Sub DisplayAttributes(reader As XmlReader)
    If reader.HasAttributes Then
        Console.WriteLine("Attributes of <" & reader.Name & ">")
        While reader.MoveToNextAttribute()
            Console.WriteLine(" {0}={1}", reader.Name, reader.Value)
        End While
    End If
End Sub 'DisplayAttributes

[C#] 
public void DisplayAttributes(XmlReader reader)
{
    if (reader.HasAttributes)
    {
        Console.WriteLine("Attributes of <" + reader.Name + ">");
        while (reader.MoveToNextAttribute())
        {
            Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
        }
    }
}

[C++] 
public:
    void DisplayAttributes(XmlReader* reader)
    {
        if (reader->HasAttributes)
        {
            Console::WriteLine(S"Attributes of <{0}>", reader->Name);
            while (reader->MoveToNextAttribute())
            {
                Console::WriteLine(S" {0}={1}", reader->Name, reader->Value);
            }
        }
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

XmlReader Class | XmlReader Members | System.Xml Namespace

Show:
© 2014 Microsoft