Export (0) Print
Expand All

XmlReader.MoveToNextAttribute Method

When overridden in a derived class, moves to the next attribute.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

'Declaration
Public MustOverride Function MoveToNextAttribute As Boolean

Return Value

Type: System.Boolean
true if there is a next attribute; false if there are no more attributes.

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.


Dim output As New StringBuilder()

Dim xmlString As String = _
    "<bookstore>" & _
      "<book genre='novel' ISBN='10-861003-324'>" & _
            "<title>The Handmaid's Tale</title>" & _
            "<price>19.95</price>" & _
        "</book>" & _
        "<book genre='novel' ISBN='1-861001-57-5'>" & _
            "<title>Pride And Prejudice</title>" & _
            "<price>24.95</price>" & _
        "</book>" & _
    "</bookstore>"

' Load the file and ignore all white space.
Dim settings As New XmlReaderSettings()
settings.IgnoreWhitespace = True
Using reader As XmlReader = XmlReader.Create(New StringReader(xmlString), settings)

    ' Move the reader to the second book node.
    reader.MoveToContent()
    reader.ReadToDescendant("book")
    reader.Skip() 'Skip the first book.
    ' Parse the file starting with the second book node.
    Do
        Select Case reader.NodeType
            Case XmlNodeType.Element
                output.AppendLine("<" + reader.Name)
                While reader.MoveToNextAttribute()
                    output.AppendLine(" " + reader.Name + "=" + reader.Value)
                End While
                output.AppendLine(">")
            Case XmlNodeType.Text
                output.AppendLine(reader.Value)
            Case XmlNodeType.EndElement
                output.AppendLine("</" + reader.Name + ">")
        End Select
    Loop While reader.Read()

    OutputTextBlock.Text = output.ToString()
End Using


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft