XmlReader.HasAttributes Property
This page is specific to:.NET Framework Version:1.12.03.03.5Silverlight 34.0
.NET Framework Class Library
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

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View