Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlValidatingReader.MoveToNextAttribute Method

Moves to the next attribute.

[Visual Basic]
Overrides Public Function MoveToNextAttribute() As Boolean
[C#]
public override bool MoveToNextAttribute();
[C++]
public: bool MoveToNextAttribute();
[JScript]
public override function MoveToNextAttribute() : Boolean;

Return Value

true if there is a next attribute; false if there are no more attributes.

Remarks

If the current node is an element node, this method is equivalent to MoveToFirstAttribute. If MoveToNextAttribute returns true, the reader moves to the next attribute; otherwise, the position of the reader does not change.

Example

[Visual Basic, C#, C++] The following example reads an XML fragment.

[Visual Basic] 
Imports System
Imports System.IO
Imports System.Xml

public class Sample 

  public shared sub Main()

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

    'Read the genre attribute.
    reader.MoveToContent()
    reader.MoveToFirstAttribute()
    Dim genre As String = reader.Value
    Console.WriteLine("The genre value: " & genre)

    'Close the reader.
    reader.Close()

  End sub
End class 

[C#] 
using System;
using System.IO;
using System.Xml;

public class Sample 
{
  public static void Main()
  {

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

    //Read the genre attribute.
    reader.MoveToContent();
    reader.MoveToFirstAttribute();
    string genre=reader.Value;
    Console.WriteLine("The genre value: " + genre);

    //Close the reader.
    reader.Close();

  } 
} // End class

[C++] 
#using <mscorlib.dll>
#using <System.Xml.dll>
using namespace System;
using namespace System::IO;
using namespace System::Xml;

int main()
{

    //Create the validating reader.
    XmlTextReader* txtreader = new XmlTextReader(S"attrs.xml");
    XmlValidatingReader* reader = new XmlValidatingReader(txtreader);

    //Read the genre attribute.
    reader->MoveToContent();
    reader->MoveToFirstAttribute();
    String* genre=reader->Value;
    Console::WriteLine(S"The genre value: {0}", genre);

    //Close the reader.
    reader->Close();

} 

[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

See Also

XmlValidatingReader Class | XmlValidatingReader Members | System.Xml Namespace

Show:
© 2015 Microsoft